Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 511
mattdwen Avatar asked Dec 19 '25 22:12

mattdwen


1 Answers

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?

like image 61
Eevee Avatar answered Dec 22 '25 12:12

Eevee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!