我有PHP脚本/ HTML
$string1 = 'Foo';
$string2 = 'Bar';
$string3 = 'This string contains some URL';
$string4 = 'This string contains multi-line short description which contains single quotes, double quotes and some comma characters as well.';
这是我的onClick
<a class="someClass" title="someTitle" href="#" onclick="someFunction('<?php echo $string1; ?>', '<?php echo $string2; ?>', '<?php echo $string3; ?>', '<?php echo $string4; ?>')">Click Here</a>
但是在接收时,我在someFunction()
答案 0 :(得分:1)
在php方面使用:
<?php echo addslashes($string1); ?>
在someFunction(string1)中使用:
string1 = string1.replace(/\\/g, '');
获取字符串的正常值;