用于生成 Javascript 和 JavaScript 的 PHP 脚本 Zend Studio 中的突出显示
我有一个 PHP 脚本,用于为 Web 应用程序生成一些相当复杂的 javascript。 出于可伸缩性的原因,该脚本必须由 PHP 生成。
这是我的问题:
如果我将文件命名为
myscript.js
,那么我必须使用 htaccess 告诉网络服务器通过 PHP 进行管道传输(不推荐)如果我将文件命名为
myscript.php
,那么 Zend Studio 会将所有代码突出显示为 HTML 而不是 javascript。
我现在所做的只是将脚本命名为 myscript.php
,并将所有代码包装在 标记中,然后执行
include('myscript.php) 。 php')
而不是首选:。
如果我可以告诉 Zend Studio 突出显示该文件,就好像它是一个 *.js
文件一样,我就可以解决整个问题。 有办法做到这一点吗?
目前我正在使用版本 5.5(适用于 Windows,在工作中)和 6.1(适用于 Linux,在家中)。
I have a PHP script that I am using to generate some rather complicated javascript for a web application. It is necessary that this script be generated by PHP for scalability reasons.
Here is my problem:
if I name the file
myscript.js
, then I have to use htaccess to tell the webserver to pipe this through PHP (not preferrable)if I name the file
myscript.php
, then Zend Studio will highlight all the code as HTML instead of javascript.
What I am doing now is simply naming the script myscript.php
, and wrapping all the code in <script>
tags, then doing include('myscript.php')
instead of the preferred: <script src='myscript.php'>
.
I could thwart this whole problem if only I could tell Zend Studio to highlight this file as though it were a *.js
file. Is there a way of accomplishing this?
Currently I am using versions 5.5 (for Windows, at work) and 6.1 (for Linux, at home).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有办法用 Javascript 编辑器打开文件吗?
比如右键单击文件名,然后“使用 > Javascript 编辑器打开”?
好吧,我刚刚尝试过 Zend Studio (我没有找到版本号,但它是一个相当新的版本,下载不到一个月 - 并且基于 Eclipse)
来查看“Javascript在“打开方式”列表中的“编辑器”中,您可能需要在 .php 和“Javascript”之间添加文件关联。 为此,请按照下列步骤操作:
现在,在文件列表中,您应该能够右键单击 PHP 文件,然后“使用 > javascript 编辑器打开”
并且您的文件应该像 JS 文件一样突出显示,而不是 PHP。
我不确定 Zend studio 是否会记住必须使用 JS 编辑器打开一个文件这一事实:您可能总是需要对您感兴趣的文件使用“打开方式”。
希望这会有所帮助;-)
Is there not a way to open your file with the Javascript editor ?
Something like right click on the file's name, then "Open With > Javascript editor" ?
Well, I've just tried with Zend Studio (I don't find the version number, but it's a pretty recent one, downloaded less than one month ago -- and Eclipse based)
To see "Javascript editor" in the "Open with" list, you might have to add a file association between .php and "Javascript". To do that, follow these steps :
Now, in the files list, you should be able to right click on a PHP file, and "open with > javascript editor"
And your file should be highlighted like a JS one, and not as PHP.
I'm not sure Zend studio will remember the fact that one file has to be opened with JS editor, though : you might always have to use "open with" for the file you are interested in.
Hope this helps ;-)
我发现了一个非常简单的 hack 可以让 zend 将 PHP 文件视为 javascript:
但我认为 Pascal 的方法更干净......
I've found a very easy hack to cause zend to think of the PHP file as javascript:
But I think Pascal's approach is cleaner...