Jump to content

[SOLVED] Escape characters not escaping...


Halyard

Recommended Posts

I am teaching myself PHP, and wrote this snippet to test escape characters:-

 

<?php

echo "This piece has been written to test escape characters,/n";
echo "especially the newline/n";
echo "character...";

?>

 

Expecting to see something like this:-

 

This piece has been written to test escape characters,

especially the newline

character...

 

Not something like this:-

 

This piece has been written to test escape characters,/nespecially the newline/ncharacter...

 

I have already done some extensive searching, and most answers seem to say that magic_quotes should be set to OFF, and all will work (Maniacial Laugh Here)

 

This from the PHP Info page:-

 

magic_quotes_gpc Off Off

magic_quotes_runtime Off Off

magic_quotes_sybase Off Off

 

So WTF is wrong - it beats me!

Link to comment
https://forums.phpfreaks.com/topic/142630-solved-escape-characters-not-escaping/
Share on other sites

And once you get the escape character correct, a \n does not have any meaning in HTML. When you output it to the browser it formats the source code of the page. You need a <br> or <br /> tag to cause a newline in the HTML content.

your slashes are the wrong way...

 

so not /n but \n

 

OMFG!!!!! The one thing I did not check! What a effing DUMMY! Talk about not being able to see the wood for the trees...

 

Thanks for spotting the bleedin obvious.

 

LOL its cool bro. We all have been there... I know I have been there on more than one several occasion!

And once you get the escape character correct, a \n does not have any meaning in HTML. When you output it to the browser it formats the source code of the page. You need a <br> or <br /> tag to cause a newline in the HTML content.

 

Ah, so maybe that's why when I changed the slashes I still got this:-

 

This piece has been written to test escape characters, especially the newline character...

 

instead of this:-

 

This piece has been written to test escape characters,

especially the newline

character...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.