2017-07-14 22 views
-2

中的双引号内使用单引号解决我由于双引号内的单引号引起错误,并且所有内容都位于$ content变量的单引号内。请问这怎么解决?

$content = ' 

setTimeout("finishAjax('usernameResult', '"+escape(response)+"')", 400); 

'; 
+4

转义引用 –

+0

$ content =“setTimeout(\”finishAjax('usernameResult','escape(response)')\“,400)”; – Programit

+0

嗨周杰伦,谢谢你的回复。但是,它仍然在第105行的C:\ xampp \ htdocs \ fm-reg \ register.php中显示错误“Parse error:syntax error,unexpected'usernameResult'(T_STRING);” – jbm59er

回答

0

为了在字符串文字中放置单引号或双引号,必须首先将其转义。 PHP中的转义字符是反斜线(\)。

$content = "setTimeout(\"finishAjax('usernameResult', '+escape(response)+')\", 400);"; 

阅读更多关于转义字符HERE

相关问题