Calling Javascript function in PHP while passing PHP variables into the function

泪湿孤枕 提交于 2019-11-29 17:07:58

Single quotes litterally puts your $var as $var. While double quotes puts your $var in 0 1 or 2

echo "<script type='text/javascript'>functionName('$var1', '$var2', '$var3');</script>"

I think you should use curly braces to better distinguish variables in a string. Just wrap them like this:

echo "<script type='text/javascript'>functionName({$var1}, {$var2}, {$var3});</script>"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!