Alex Rivera | Logout

How to use single quote inside an echo which is using single quote

Asked 2012-08-03T09:29:05.520
20

First of all, i have gone through the related questions.. haven't found any answer.. I m using this code to display a message

echo 'Here goes your message with an apostrophe S like thi's ';

How can i make this work, as any quote inside this echo will break the statement...

Edit
Report

1 Answer

38

Either escape the quote with a backslash, or use double quotes to designate the string.

echo 'Here goes your message with an apostrophe S like thi\'s';

echo "Here goes your message with an apostrophe S like thi's";
answered 2012-08-03T09:31:15.410

Your Answer