且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Netbeans PHP/javascript突出显示

更新时间:2022-06-22 08:02:37

如果文件中仅使用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..*/
?>