Ok, i'm having a problem loading pages where the php script begins with

<?

instead of <?php

I've set short_open_tag to "On" in my php.ini file, have rebooted IIS(version 5), and even rebooted my server(windows 2000).

I've triple checked the php.ini file and this variable is definately set to on. Any idea what's happenning?

Changing the code is not an option. It's not my code actually, i'm trying to use phplive which is 3rd party software.

PHP code does work expected when the tags begin with <?php. I can reproduce the problem even with the following script:

<?
phpinfo();
?>

Thanks for any help!

    Well, you should consider updating your scripts to "<?php ... ?>" since, apparently, in PHP6, "<? ?>" won't be supported anymore...

      Can you show us the exact syntax you used in the php.ini file? It should look like:

      short_open_tag = On
      

      (Though I'd agree that the better long-term solution would be to leave it off and update your scripts to the current best practice of always using long open tags.)

        You should seriously consider the above suggestions of switching to the full "<?php" tag. Those three extra little letters can save you a lot of time now and in the future.

        If you use the full "<?php" tag and do a phpinfo(), does it show that the short_open_tag is On ? If not, it looks like PHP isn't reading your php.ini file, and you'll need to add the PHPRC environment variable.

          7 months later

          Hello evryone,

          I have the same issue as Marcus where PHP is not recognizing <? although short_open_tag is on. I also have code that I can't change and wanted to check if this is a known issue in PHP5.2.3

          I'm running PHP on Windows Vista with IIS7 and all works well when my tag looks like <?PHP

          Any suggestions or input?
          Marcus what did u end up doing?

            What is the output of this script:

            <?php
            var_dump(ini_get('short_open_tag'));
            ?>
            

            PS: And the best solution is still to always use long tags.

              Hi NogDog,

              I agree with you on the fact that "And the best solution is still to always use long tags.", and I personally use that convention. But I really had to find a way around this script that I have.

              Now since I posted this post, I kept testing and I added the PHPRC environment variable but it did not seem to have any effect. Now, 20 minutes late, and while testing the output of what u sent, I noticed that it gave:
              string(1) "1"

              And the issue is solved. It seems all the changes done needed some time to propagate (as weird as this sounds).

              Thanks for the prompt reply.

              Happy meπŸ™‚

                <?php
                //long_open_tags.php
                $sr = array(
                	'<?='=>'<? echo',
                	'<?'=>'<?php ',
                	'<?php php'=>'<?php',
                	'<?php xml'=>'<?xml',
                	'<?php  '=>'<?php ');
                
                file_put_contents(
                	$argv[1],
                	str_replace(
                		array_keys($sr),
                		array_values($sr),
                		file_get_contents(
                			$argv[1])));
                ?>
                
                php long_open_tags.php problem_script.php
                

                  That's pretty handy, Weed. I would think something like this would work for doing all the scripts in a project directory:
                  $ php long_open_tags.php $(find ./ -iname ".php")

                  Granted, then he'd need to be on Linux instead of vista, but it's kinda handy if I ever come across a project that still uses short tags.

                    Another way to skin that cat...

                    <?php
                    function fix_tags($text)
                    {
                       $search = array(
                          '/<\?=(.*?)\?>/' => '<?php echo \\1;?>',
                          '/<\?(?!php|xml)/i' => '<?php'
                       );
                       return(preg_replace(array_keys($search), $search, $text));
                    }
                    
                      Write a Reply...