|
-
Goldfish
php problem
I decided to finally learn php and so I installed both apache and php on my laptop computer (laptop runs under XP) and run it as a server so i could go and do stuff.
I was going through the ol hello world stuff and everything was going fine until i got to the special characters part
if I go and do this
<?php
echo "Hi my name is \nCaesar";
?>
it is supposed to output this:
Hi my name is
Caesar
right ??
but it's not doing it ! what is actually shows is:
Hi my name is Caesar <-- without the newline
however when i view the source on explorer it does shows like it is supposed to (with the newline thing)
same thing happens with \r and \t
doesnt happen with the other special chars... if I go and do this
echo "Hi my name is \$Caesar";
it does indeed shows
Hi my name is $Caesar
so... can somebody help me ?
-
Ursus Arctos Moderatis
PHP did it's job by printing the new line character, you're just no understanding the nature of HTML.
HTML has a "<br>" tag for line breaks. New line characters in the source code mean absolutely nothing to the HTML parser. You have to remember that all whitespace characters are ignored by the HTML parser. (new lines are considered whitespace)
However, if you want new line characters to actually display line breaks on your web page, simply wrap your content in the "<pre></pre>" tag.
-
Goldfish
I tought the PHP did the parsing part
but I guess that makes more sense
thank you
Last edited by Caesar War; 01-04-2003 at 05:57 PM.
-
Ursus Arctos Moderatis
PHP parses PHP code on the server-side, and the web browser parses the resulting HTML on the client-side. Make sense?
-
Goldfish
yup... thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|