Welcome! Log In Create A New Profile


Topic 4A

Posted by allenvd 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Topic 4A
July 19, 2006 10:16PM
The prescribed book mentions that $_GET, $_POST, $_REQUEST should be used in future in stead of HTTP_POST_VARS, etc. With register_globals set to off for security reasons.

I assume we will follow the instructions of the prescribed book for php5 onwards ?

Is using the <br> tag on its own sufficient or should one include the \n newline tag as well ?
Re: Topic 4A
July 20, 2006 08:36AM
it could be a preference thing?

I am also using PHP5 and had no problems with just using <br /> - so far - that is when used in the echo context.
Re: Topic 4A
July 23, 2006 11:11AM
It all depends which version of PHP you will be working with in future - so its good to know about both. <br/> or \n is indeed a preference decision. It won't impact the code - you can echo any html tags. I'm used to <br/> so I use it.
Re: Topic 4A
July 27, 2006 09:48PM
Hi Allen

You are correct, using $_GET, $_POST, $_REQUEST variables, and SESSION variables instead of globals is the way to go, the other options are becoming more and more obsolete.

Also, don't assume <br> and \n do the same thing, they don't. <br> is an html tag, \n is has nothing to do with html, but is actually an ASCII command for linefeed. In fact, linefeed usually occurs after a carriage return command, i.e. \r\n (carriage return - linefeed).

The only reason you would want to use it, is if you wanted your "view source" code to look nicely formatted, or if it were a requirement of a dynamically generated file export.

Take for example the following php source:

echo "one<br>";
echo "two<br>";
echo "three<br>";
echo "four<br>";

The output would be, as required:


and if you did the "view source" thing, you would see:


not too reader friendly. But if your php source was:

echo "one<br>\r\n";
echo "two<br>\r\n";
echo "three<br>\r\n";
echo "four<br>\r\n";

the output would be the same:


but if you wanted to "view source", you would see:


note the formatting is much better, especially if you are debugging complex tables etc, but the output is exactly the same.

If your php source code was:

echo "one\n";
echo "two\n";
echo "three\n";
echo "four\n";

your output would be:

one two three four

Not quite the desired effect!

So, you will need to stick to the html tag <br> if you require a linebreak in your web page, and you can add \n or \r\n if you want your "view source" code to look nice, but they are not the same thing. As you suggested in your original post, use both and you won't go wrong.


Re: Topic 4A
August 07, 2006 07:08AM
Topic 4A completed.
Re: Topic 4A
September 11, 2006 11:04AM
Re: Topic 4A
September 13, 2006 09:29PM
Topic 4A completed.
Re: Topic 4A
September 17, 2006 09:09PM
4A completed
Re: Topic 4A
September 18, 2006 08:04PM
avatar Re: Topic 4A
September 19, 2006 10:30PM
It has been completed.
Sorry, only registered users may post in this forum.

Click here to login