I am sure there must be a better way than putting a backslash (\
) to escape double quotes in php
Suppose i have the following
<param name="flashvars" value="config={clip:{autoPlay:true,autoHide.....
The value
consist of many "
and '
and its getting tedious adding \
before every "
You can use heredoc
$mystring = <<<LOL
<param name="flashvars" value="config={clip:{autoPlay:true,autoHide "double quotes" and 'single quotes',plus $variables too...
LOL;
Or simply:
echo <<<LOL
<param name="flashvars" value="config={clip:{autoPlay:true,autoHide "double quotes"and 'single quotes', plus $variables too...
LOL;
You can use addslashes
in this case. Don't use it for queries to a database though. Use specific escape functions for that.
$param = "config={clip:autoPlay:True,autoHide..."; // put full value here
And then in your HTML:
<param name="flashvars" value="<?php echo addslashes($param) ?>">