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
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
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.

 

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.