在PHP语法错误中回显jquery-找不到我的错误 [英] echo jquery in PHP syntax error - can't find my mistake
本文介绍了在PHP语法错误中回显jquery-找不到我的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在PHP中回显jQuery,但是无论执行什么操作都会给我以下错误:
I try to echo out jQuery in PHP but it gives me following error whatever I do:
Parse error: syntax error, unexpected 'foreach' (T_FOREACH), expecting ',' or ';' in /var/www/html/login/application/controllers/sellercentral.php on line 309
代码:
echo '<script>
$( document ).ready(function() {
$("#Drafts > tbody:last").append('foreach($this->central as $key2 => $value2) {
'<tr>
<td><a href='. $value2->Token .'>Edit</a></td>
<td class=T id='. $value2- >Token.'>'.htmlentities($value2->Title).'</td>
</tr>
'.}.' );
});
</script>';
推荐答案
您不能在echo语句中使用foreach!像这样分解它们:
You can't use a foreach in a echo statement! Just break them up like this:
echo '<script>
$( document ).ready(function() {
$("#Drafts > tbody:last").append(';
foreach($this->central as $key2 => $value2) {
echo '<tr>
<td><a href='. $value2->Token .'>Edit</a></td>
<td class=T id='. $value2- >Token.'>'.htmlentities($value2->Title).'</td>
</tr>';
}
echo ');});</script>';
这篇关于在PHP语法错误中回显jquery-找不到我的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文