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...
' End first quotation which uses single quotes. " Start second quotation, using double-quotes. ' Quoted character. " End second quotation, using double-quotes.
A single quote is not used where there is already a quoted string. So you can overcome this issue by using a backslash following the single quote. Here the backslash and a quote are used in the “don't” word. The whole string is accompanied by the '$' sign at the start of the declaration of the variable.
The Single QuotesCharacters within single quotes are quoted just as if a backslash is in front of each character. With this, the echo command displays in a proper way.
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";
Escape the quote using a backslash.
'hello\'s'
The single quote that appears after the backslash will appear on screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With