在JS文件中的PHP代码上禁用语法错误突出显示-PHPStorm [英] Disable Syntax Error Highlights on PHP Code in a JS File - PHPStorm

查看:309
本文介绍了在JS文件中的PHP代码上禁用语法错误突出显示-PHPStorm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将页面的JS代码保存在单独的.js文件中(即,"properties.php"视图将具有"properties.js"脚本文件.在JavaScript文件中,我有一些PHP变量供我使用) JS之类的东西

I keep my pages' JS code in a separate .js file (ie. "properties.php" view would have a "properties.js" script file. In the JavaScript files, I have some PHP variables which I use with the JS. Something like:

var var1 = <?php echo $var1; ?>

以上内容不会在文本编辑器中触发任何语法错误.有时候我会用到更长的PHP代码:

The above doesn't trigger any syntax errors in the text editor. Sometimes I'll have PHP code that's a little longer:

var left_by_user_id = <?php
                                    if(isset($id)){
                                        echo $id;
                                    }
                                    else{
                                        echo 0;
                                    }
                      ?>;

这将触发在编辑器中突出显示语法错误.有什么方法可以禁用封装在PHP括号中的内容的突出显示吗?

This will trigger syntax error highlighting in the editor. Is there any way to disable highlighting for anything encapsulated in PHP brackets?

推荐答案

我转到设置"->文件类型".在识别的文件类型"窗口窗格上,我选择了"PHP文件(PHP)".在正下方的已注册模式"窗格中,出现了相关文件扩展名的列表.我已经用"jsphp"扩展名重命名了所有的JS视图文件.我在注册模式"窗格中添加了"jsphp".

I went to "Settings"->"File Types". On the "Recognized File Types" window pane, I selected "PHP files (PHP)". In the "Registered Pattern" pane directly below, a list of associated file extensions come up. I had renamed all of my JS view files with the extension of "jsphp". I added "jsphp" to the "Registered Pattern" pane.

然后在设置"窗口的目录窗格中,单击模板数据语言".我找到了保存所有JS视图文件的文件夹. 模板数据语言"窗格中有两列.左侧是目录名称/路径.右侧是一列,称为模板数据语言".我将模板数据语言"列上的JS视图文件夹的值更改为"JavaScript 1.8".

Then on the directory pane of the "Settings" window, I clicked on "Template Data Languages". I found the folder where I kept all of my JS view files. There are two columns in the "Template Data Languages" pane. On the left side is the directory name / path. On the right side is a column called "Template data language". I changed the value for my JS views folder on the "Template data language" column to "JavaScript 1.8".

编辑器现在可以识别位于该特定目录中的文件中的JS和PHP.

The editor will now recognize both the JS and PHP in files locted in that particular directory.

这篇关于在JS文件中的PHP代码上禁用语法错误突出显示-PHPStorm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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