简体   繁体   English

停止 PHP 执行<!--? within javascript</div--><div id="text_translate"><p> 我正在尝试实现 TinyMCE,它在我的测试平台上运行良好,但在生产服务器上,PHP 正在尝试执行一些'&lt;?' tiny_mce.js文件中的标签。</p><p> 我有一个名为html_editor.php的文件,它被引入到需要使用include_once的每个表单中。 在html_editor内,我有以下内容:</p><pre> &lt;script type="text/javascript" src="/Public/TinyMCE/tiny_mce.js"&gt;&lt;/script&gt;</pre><p> 随后是 Tiny MCE 初始化,但它在该行上因unexpected T_CONSTANT_ENCAPSED_STRING 。 我用tiny_mce_src.js替换了脚本文件,以找到导致问题的确切代码,它是:</p><pre> html.push('&lt;?', name, ' ', text, '?&gt;');</pre><p> 我在tiny_mce_src.js中用双引号交换了单引号,这确实解决了问题,但在缩小的代码中,它们已经是双引号了。</p><p> 这显然是我的测试服务器和生产服务器之间与 PHP 的配置差异,但我无法追踪是什么。 我正在使用 PHP 5.3 进行测试,并且服务器正在运行 5.2。</p></div>

[英]Stop PHP executing <? within javascript

I'm trying to implement TinyMCE, which is working fine on my test rig, but on the production server, PHP is trying to execute some '<?'我正在尝试实现 TinyMCE,它在我的测试平台上运行良好,但在生产服务器上,PHP 正在尝试执行一些'<?' tags which are in the tiny_mce.js file. tiny_mce.js文件中的标签。

I have a file called html_editor.php , which is brought into each form which requires it using include_once .我有一个名为html_editor.php的文件,它被引入到需要使用include_once的每个表单中。 Inside html_editor , i have the following:html_editor内,我有以下内容:

<script type="text/javascript" src="/Public/TinyMCE/tiny_mce.js"></script>

followed by the Tiny MCE initialization, but it's failing on that line with unexpected T_CONSTANT_ENCAPSED_STRING .随后是 Tiny MCE 初始化,但它在该行上因unexpected T_CONSTANT_ENCAPSED_STRING I replaced the script file with tiny_mce_src.js to find the exact code which is causing the problem, and it's:我用tiny_mce_src.js替换了脚本文件,以找到导致问题的确切代码,它是:

html.push('<?', name, ' ', text, '?>');

I've swapped the single quotes with doubles in tiny_mce_src.js , which does resolve the problem, but in the minified code, they're already double.我在tiny_mce_src.js中用双引号交换了单引号,这确实解决了问题,但在缩小的代码中,它们已经是双引号了。

It's obviously a configuration difference with PHP between my test and production servers, but I can't track down what.这显然是我的测试服务器和生产服务器之间与 PHP 的配置差异,但我无法追踪是什么。 I am testing with PHP 5.3, and the server is running 5.2.我正在使用 PHP 5.3 进行测试,并且服务器正在运行 5.2。

Why are JavaScript files going through the PHP interpreter?!为什么 JavaScript 文件要通过 PHP 解释器?!

Fix your server configuration to only treat *.php as PHP.修复您的服务器配置以仅将*.php视为 PHP。 How to do this depends on the web server you use and how you're running PHP;如何执行此操作取决于您使用的 web 服务器以及您如何运行 PHP; can you paste your test and production configurations?你能粘贴你的测试和生产配置吗?

you need to edit php.ini and set您需要编辑 php.ini 并设置

short_open_tag=0

this will stop这将停止

being processed, its a good idea regardless, then make suer all your php scripts use正在处理,无论如何这是一个好主意,然后让你所有的 php 脚本使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM