Netbeans PHP/javascript突出显示 [英] Netbeans PHP/javascript highlighting

查看:98
本文介绍了Netbeans PHP/javascript突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当PHP与Javascript混合使用时,我一直在寻找针对NetBeans(7.1.1)突出显示代码中错误错误的解决方案.我也使用Notepad ++,它对此没有任何问题.

I've been searching all over for a solution to faulty errors in the code highlighting for NetBeans (7.1.1) when mixing PHP with Javascript. I also use Notepad++ which has no problems with this.

示例:

function showUpload<?php echo $upload;?>(file) { /* JS-code */ }

或:

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

我确实找到了一些解决方法,但是我拒绝为我的IDE更改代码!!! (IDE应该帮助我编码,而不是使事情变得更困难)

I did find some work-arounds, but I refuse to change code for my IDE!!! (The IDE should help me code, not make things more difficult)

有人知道这个问题的实际解决方案吗?

Does anyone know of an actual solution to this problem?

推荐答案

如果文件中仅使用JavaScript + PHP组合(不包含HTML),只需打开要突出显示JavaScript语法的文件,然后添加这行:

If you're using only JavaScript + PHP combinations in your file (without HTML), just open the file in which you want to highlight JavaScript syntax, and add this line:

//<script type="text/javascript">

在页面顶部

,然后打开第一个PHP标记,如下所示:

on the top of the page before opening the first PHP tag like this:

//<script type="text/javascript">
<?php
/*The rest of the code..*/
?>

此文件中的所有JavaScript代码均应正确突出显示.

All JavaScript code in this file should be properly highlighted.

如果文件中间某处有HTML代码,则需要在HTML代码之前关闭JavaScript标记,然后在HTML代码之后重新打开它,如下所示:

In case that you have HTML code somewhere in the middle of the file, you would need to close JavaScript tag before HTML code, and to re-open it again after HTML code like this:

//<script type="text/javascript">
<?php
/*The rest of the code..JavaScript + PHP*/

//</script>
<h1>HTML code</h1><!--HTML code only-->
<p>Bla bla..</p>
//<script type="text/javascript">

/*JavaScript + PHP code again*/

?>

如果您不希望将这些注释打印到最终的HTML文档中,则可以在文档顶部创建伪造的PHP函数,该函数永远不会被您使用,只能由IDE使用,如下所示:

If you don't want these comments to be printed out to your final HTML document, you can create fake PHP function that will never be used by you, only by IDE, on the top of the document like this:

<?php
function higlightJavaScriptCode(){
    ?>
    //<script type="text/javascript">
    <?php
}
/*The rest of the code..*/
?>

这篇关于Netbeans PHP/javascript突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆