I\'m experiencing a problem when calling a JavaScript function inside PHP code and trying to pass my PHP variables as parameters into the function. While it seems really sim
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>"
Single quotes litterally puts your
$var
as$var
. While double quotes puts your$var
in0 1 or 2
echo "<script type='text/javascript'>functionName('$var1', '$var2', '$var3');</script>"