How can i use string like below code.
$str = 'Is yo"ur name O'reil"ly?';
The above code is just an example..I need to use big html template which contains single and double quotes.I tried Addslashes php method but when i use single and double quote string in that function i get syntax error.Please help me.
Note : my realtime usage is json data like below.
$string = "
<html>
...
<b:if cond='data:blog.pageType == "item"'>
..
";
$string = '{"method":"template","params":{"1":"'.$string.'"},"token":"12345"}';
You can use a heredoc for that:
$string = <<<EOM
<html>
...
<b:if cond='data:blog.pageType == "item"'>
..
EOM;
If you wish to prevent variable interpolation as well you can use nowdoc (since 5.3):
$string = <<<'EOM'
<html>
...
<b:if cond='data:blog.pageType == "item"'>
..
EOM;
Both heredoc and nowdoc have specific formatting requirements, so be sure to read the manual properly.
I used heredoc to do the same like
$string = <<< EOF
'Is yo"ur name O'reil"ly?'
EOF;
You can use heredoc like this:
$str = <<< EOF
'Is yo"ur name O'reil"ly?'
EOF;
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