PHP Short Opening Tag not supported… null problemo!

January 20, 2008 – 9:28 pm

Here’s another config - particularity of PHP, right up there with my beloved register_globals run-ins and $_REQUEST access issues..
Recently I’ve had to deploy a site on a server that had short opening tags disabled, and no access to the php.ini. Wow, didn’t see that coming.

Now, for my scripts that didn’t really mean a thing, since I habitually start a multi-line php code block with <?php, however, I do like using <?= within my “templates” (or view files), rather than <?php echo, because, well it keeps things “template-ier” IMHO. Almost as short as the smarty tag, eh? ;)

So what to do avoid string replacing the hell out of your front-end?

Luckily, you can use the .htaccess file to set directory specific configuration. Simply put

php_flag short_open_tag on

somewhere in there, and things start working, IF your server administrator allows it, which should be the case..

That being said, I realize this is a quick fix, and in code meant for distribution I would probably use string replace before shipping, just to make sure things work right out of the box.

Here’s a question: I read somewhere that using the runtime version

ini_set('short_open_tag', 1);

withing your code doesn’t seem to work. I haven’t tried it for myself.. maybe somebody can comment on that?

Filed under: Rnadom Sftuf — by Richtermeister

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress