开发者

Javascript function argument error

I'm using the following function:

<body onload="testing(<?php print "'". $_SESSION['data'] . "'"; ?>);">

if $_SESSION['data'] = "My name is function" then it works fine but

if $_SESSION['data'] = "Calling jackson's function" then it gives error.

Can you tell me how can i pass an argument which may contain characters like

$_SESSION['data'] = "Calling jackson's function"

into the testing functi开发者_开发百科on parameters.


Escape them with addslashes()

echo "'" . addslashes($_SESSION['data']) . "'";


You could do:

<body onload="testing(<?php print "'". addslashes($_SESSION['data']) . "'"; ?>);">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜