Forum Moderators: coopster

Message Too Old, No Replies

Echo error from ' in text.

Simple but my mind is blank

         

sauce

7:09 pm on Aug 31, 2005 (gmt 0)

10+ Year Member



I keep getting this eror and my mind is blank on how to fix it...

Basically, how do you code in apostrophes (') in echo 'text'

I'm getting this error: Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in

because in my echo i have a floating ' in the text...:

echo '<b>You must enter at least one friend's email</b>';

JAB Creations

7:12 pm on Aug 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The backslash... \

Who\'s dirty sock is this?

coopster

7:23 pm on Aug 31, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



And you can read more about it in the PHP manual page regarding Strings [php.net]. Very handy!

dreamcatcher

8:11 pm on Aug 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The other way is to enclose the echo in double quotes:

echo "<b>You must enter at least one friend's email</b>";

But if you use double quotes in the string, this will give you a similar error.

dc

sauce

8:36 pm on Aug 31, 2005 (gmt 0)

10+ Year Member



\' backlash worked. Thanks! For some reason I kept coding it like \"'\"... one of those days...

Thanks for the PHP resource too.