I'm embedding a javascript syntax highlighter to a PHP script that reads source file and echos it back. The js highlighter has this string on one line:
... [z,/^[^<?]+/], ...
The short_open_tag is on on this server and the <?
in the string confuses the script and causes errors. I cannot turn off in php.ini or elsewhere.
I have used ini_set('short_open_tag', '0');
in the same script, but it does not take effect. What could be the problem?
Edit
In the end, I used what Col Shrapnel suggested in a comment:
I changed [z,/^[^<?]+/],
to [z,/^[^<?php echo '<' .'?'; ?>]+/],
'short_open_tag' is marked as PHP_INI_PERDIR in PHP <5.3.0, which means you can't change it with ini_set().
According to a comment on this manual page:
libkhorse at gmail dot com 06-Aug-2009 07:14:
For 'short_open_tag', though it is marked as PHP_INI_ALL in changable column, you should note the CHANGE_LOG column also:
PHP_INI_ALL in PHP <= 4.0.0. PHP_INI_PERDIR in PHP < 5.3.0
So as of 4.0, it will not work if you wanna use ini_set('short_open_tag') to change it's value on the fly.
Try using .htaccess
instead:
php_flag short_open_tag off
I see no connection between your highlighter and turning short open tags off.
If some of your code gets confused with short tags, you have to rewrite your code manually, replacing short tags with long ones. Or at least run some code to do it.
But no configuration setting will do it for you.
Also, I see no way for JavaScript code to read PHP file source with all these whatever short or long tags.
It seems your problem is somewhere else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With