tags:

views:

801

answers:

9

I was using xampp to develop locally and then I installed the PHP from the direct installer. Now in some of my PHP code, only PHP code that starts with "<?php" is correctly parsed. Anything that starts with "<?" or "<?=" is completely ignored and just left as is.

How can I adjust the configuration to parse either tokens?

+16  A: 

This is a php.ini setting named

short_open_tag = 1 # (enabled)
Karsten
Yes I know, but which settings?
Stephane Grenier
@Stephane: http://php.net/manual/en/ini.core.php
Svish
+2  A: 

You can set short_open_tag = On in the php.ini

Sebastian Dietz
+1  A: 

It's a configuration option, more information on: http://www.php.net/ini.core (look for short_open_tag).

J. Pablo Fernández
+13  A: 

I recommend you to disable short_open_tag and only work with <?php. When short_open_tag is enabled, it can collide with the XML processing instruction <?xml as both the PHP open tag and XML PI start with a <?.

Gumbo
You can sidestep it by doing this: <? echo "<?xml.."; ?>
Sam152
+4  A: 

By using only <? as start preprocessor startup, you can get the preprocessor confused with well formed XML documents. XML stands <? for processing-instruction, imagine an XHTML document with embeded XML that requires XSLT processing... The preprocessor will get confused with the stylesheet processing instruction and will throw an error.

It's higly recomended to use the <?php processor starting tag, try using the short_open_tag = Off in your php.ini. Also, you can try using *<php ini_set('short_open_tag', 'On'); >* if you are getting problems.

daniel
A: 

When the server is IIS 5 and .net framework is installed, although set short_open_tag=On , "<?" does not work. I couldn't find the way to enable it...

+1  A: 

The best thing about short tags though is

<?= 'Hello World' ?>

this equates to

<?php echo 'Hello World' ?>

So short tags have there usage and are prevalent all over Zend Framework Documentation

Anyway off topic as to why it doesnt work but answering Gumbo as to why sometimes its good and useful to have it enabled.

Ian Warner
A: 
tejas
A: 

My Configuration is Window 7, IIS 7 and Installed PHP 5.2.12 and edited the php.ini with short_open_tag = On; and after that restarted IIS, in new broweser window but it did not recognised the short open tag; any help would be greatly appreciated.

Saurabh