找不到语法错误
问题描述:
我有以下代码:
onclick=" <?php echo 'postwith(\''.$_SERVER['PHP_SELF'].'\',{export:\'export\',date:\''.$_POST['date'].'\'})'; ?>"
而postwith是一个函数.
while postwith is a function.
在即我有一个错误:
Expected identifier, string or number
in ie i have an error:
Expected identifier, string or number
在Firefox中可以,链接为:
in firefox it's ok and the link is:
postwith('/page/page.php',{export:'export',date:'Yesterday'})
那我的错误在哪里?
谢谢!
答
沃伦(Warrenm)指出export
是关键字,需要加引号.
As warrenm pointed out export
is a keyword and needs to be quoted.
也就是说,更改PHP,使结果输出为:
That is, alter the PHP so the result output is:
postwith('/page/page.php',{'export':'export','date':'Yesterday'});
您的PHP将如下所示:
Your PHP would look like this:
onclick="<?php echo "postwith('{$_SERVER['PHP_SELF']}',
{'export':'export','date':'{$_POST['date']}'})"; ?>"
(谢谢Peter的改进语法).
(Thanks, Peter for the improved syntax).
此外,您可能希望在单击后删除空格:
Also, you may wish to remove the space after onclick:
onclick=" <?php
将变为:
onclick="<?php