Netbeans - 在 javascript 中使用 php 进行语法检查错误
当我在 JavaScript 中使用 PHP 时,Netbeans 7.0 将行突出显示为语法错误
在我的情况下,
<script type="text/javascript">
$(document).ready(function(){
$("#rating_<?=$coObj->company_id?>").jRating({
step: true,
longStarsPath:"include/jrating/jquery/icons/btn_black_trans2.png",
rateMax:1,
phpPath:"include/jrating/php/jRating.php",
<?php
if($_SESSION["rate_of_".$coObj->company_id] == 1)
echo 'isDisabled: true,';
else
echo 'isDisabled: false,';
?>
type:'long',
length : 1,
decimalLength : 0,
rateMax: 1,
onSuccess : function(){
alert('Success : your rating has been saved');
location.reload(true);
},
onError : function(){
alert('Error : please retry');
}
});
});
</script>
PHP 代码下面的所有行都突出显示,第一行表示 missing : after property id
Netbeans 7.0 is highlighting lines as syntax error when i use PHP inside JavaScript
In my case
<script type="text/javascript">
$(document).ready(function(){
$("#rating_<?=$coObj->company_id?>").jRating({
step: true,
longStarsPath:"include/jrating/jquery/icons/btn_black_trans2.png",
rateMax:1,
phpPath:"include/jrating/php/jRating.php",
<?php
if($_SESSION["rate_of_".$coObj->company_id] == 1)
echo 'isDisabled: true,';
else
echo 'isDisabled: false,';
?>
type:'long',
length : 1,
decimalLength : 0,
rateMax: 1,
onSuccess : function(){
alert('Success : your rating has been saved');
location.reload(true);
},
onError : function(){
alert('Error : please retry');
}
});
});
</script>
all the lines below PHP code are highlighted, and first line says that missing : after property id
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@马雷克:
我并不真正认为这是一个答案,更多的是一种解决方法(这并不总是有效)...
NetBeans 应该让事情变得更容易,而不是让我们改变语法以避免它在突出显示中失败...
无论如何,我使用大量混合的 Javascript/PHP 代码,NetBeans 到处都失败了...我也使用 Notepad++,它没有任何问题...
示例:
或者:
有谁知道更好的解决方案OP的问题?!?
@Marek:
I don't really see that as an answer, more of a workaround (which doesn't always work)...
NetBeans should make things easier, not make us change syntax to avoid it failing in the highlighting...
Anyways, I use a lot of mixed Javascript/PHP code, and NetBeans fails miserably all over the place...I also use Notepad++ which doesn't have any problems with this...
Example:
Or:
Does anyone know of a better solution to the OP's question?!?
将您的语法编辑为:
edit your syntax to this: