[英]Using a HTML and Javascript Function call into PHP variable
I have a Problem with using a HTML into PHP variable. 我在HTML变量中使用HTML时遇到问题。 Please see the example below ?? 请参见下面的示例
$htmlvariable = "<a onclick="calledfunction('string',javascriptvariable);">Calling</a>";
Use single quotes and escape single quotes inside the string with a \\
: 使用单引号,并在字符串中使用\\
将单引号转义:
$htmlvariable = '<a onclick="calledfunction(\'string\',javascriptvariable);">Calling</a>';
Otherwise, this will produce this error : 否则,将产生此错误:
Parse error: syntax error, unexpected T_STRING 解析错误:语法错误,意外的T_STRING
包括那些"
在PHP双引号字符串,你需要转义:
$htmlvariable = "<a onclick=\"calledfunction('string',javascriptvariable);\">Calling</a>";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.