Netbeans - 在 javascript 中使用 php 进行语法检查错误

发布于 2024-11-05 03:03:23 字数 988 浏览 3 评论 0原文

当我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月打碎记忆 2024-11-12 03:03:23

@马雷克:
我并不真正认为这是一个答案,更多的是一种解决方法(这并不总是有效)...

NetBeans 应该让事情变得更容易,而不是让我们改变语法以避免它在突出显示中失败...

无论如何,我使用大量混合的 Javascript/PHP 代码,NetBeans 到处都失败了...我也使用 Notepad++,它没有任何问题...

示例:

function showUpload<?php echo $upload_number;?>(file) { /*some code*/ }

或者:

$('.option-help').qtip({
    content: function(api) { return $(this).parent().attr('data-tip'); },
<?php if ($option_help == 'icon') { ?>
    show: { event: 'click' },
<?php } ?>
    position: {my: 'bottom left',at: 'top left'}
});

有谁知道更好的解决方案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:

function showUpload<?php echo $upload_number;?>(file) { /*some code*/ }

Or:

$('.option-help').qtip({
    content: function(api) { return $(this).parent().attr('data-tip'); },
<?php if ($option_help == 'icon') { ?>
    show: { event: 'click' },
<?php } ?>
    position: {my: 'bottom left',at: 'top left'}
});

Does anyone know of a better solution to the OP's question?!?

や三分注定 2024-11-12 03:03:23

将您的语法编辑为:

isDisabled:<?php
    if($_SESSION["rate_of_".$coObj->company_id] == 1)
        echo 'true';
    else
        echo 'false';
    ?>,

edit your syntax to this:

isDisabled:<?php
    if($_SESSION["rate_of_".$coObj->company_id] == 1)
        echo 'true';
    else
        echo 'false';
    ?>,
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文