Is it possible to enable php short-open-tag for a single script ??
The solutions that i have gone through mention adding short_open_tag=On in php.ini
or
php_value short_open_tag 1 to .htaccess
Can’t we enable them under a php script like we enable error reporting..??
TL;DR – No, those are the only two options you have.
If you can’t do any of the mentioned methods, you will need a container script that sets the value before including the script with short open tags.This will prevent a parse error in
myscript.phpdue to short open tags.The documentation isn’t very clear about this, but apparently this stopped working since PHP 4 after which it can only be changed using
.htaccessor editingphp.ini. This excerpt seems to imply that it might work from 5.3 onwards:But that’s not the case, as can be seen from answers of Cannot turn off short_open_tag with ini_set
I’ve lodged a bug report for this documentation issue.
Update
The documentation will be updated to reflect this behaviour more explicitly: