简体   繁体   English

unescape无法从php转换为javascript

[英]unescape not working from php to javascript

Why my onclick function cannot unescape single quotes.

This is the format: = ' " ' ' ' ' " ' The single quotes inside the double quotes are messing up my code. 这是格式:='“''''''双引号内的单引号使我的代码混乱。 Here's my sample code: 这是我的示例代码:

  <?php
     $myfunction = 'onclick="tinyMCE.execCommand('mceInsertContent',false,'<img
     src=icon.gif>');return false;"'
     ?>

I tried: 我试过了:

using \\' 使用\\'

---------------------------- and also - - - - - - - - - - - - - - 并且

assigning a variable like this 分配这样的变量

$ggg = "('mceInsertContent',false,'');return false;"; $ ggg =“('mceInsertContent',false,'');返回false;”; .' 。”

of course the single quotes will mess up your code as from the PHP's viewpoint it isn't executable code, it is just a string, which should properly escaped by you using \\ backslash like this: 当然,单引号会使您的代码混乱,因为从PHP的角度来看,它不是可执行代码,它只是一个字符串,您应该使用\\反斜杠将其正确地转义,如下所示:

 <?php
 $myfunction = 'onclick="tinyMCE.execCommand(\'mceInsertContent\',false,\'<img
 src=icon.gif>\');return false;"'
 ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM