简体   繁体   中英

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 '<?' tags which are in the tiny_mce.js file.

I have a file called html_editor.php , which is brought into each form which requires it using include_once . Inside html_editor , i have the following:

<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 . I replaced the script file with tiny_mce_src.js to find the exact code which is causing the problem, and it's:

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.

It's obviously a configuration difference with PHP between my test and production servers, but I can't track down what. I am testing with PHP 5.3, and the server is running 5.2.

Why are JavaScript files going through the PHP interpreter?!

Fix your server configuration to only treat *.php as PHP. How to do this depends on the web server you use and how you're running PHP; can you paste your test and production configurations?

you need to edit php.ini and set

short_open_tag=0

this will stop

being processed, its a good idea regardless, then make suer all your php scripts use

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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