我的代码中出现此错误..
echo "<input type='button' value='send mails' onclick=\"sendmails(".$sendQuestion.")\">";
我觉得发布这个问题有点愚蠢。但我无法弄清楚这段代码有什么问题
这段代码是用php编写的。如果我不在 sendmails 函数中传递任何参数,它就可以正常工作,但是当我传递参数时,它会给出错误:
missing ) after argument list
sendmails(Type your Question here testin to post from chrome)
最佳答案
在其周围添加引号:
echo "<input type='button' value='send mails' onclick=\"sendmails('".$sendQuestion."')\">";
如果没有引号,JavaScript 会误读您的字符串。
关于php - 通过函数传递参数时出错。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1235714/