I have just upgraded my LAMP server to PHP 5.1.1. Now my all my pages on all my sites are messed up. I have figured out that it is because I donot use <?php ... ?> to write php in. i just use <? ... ?>. Seems without the "php" in the tag it will not display properly.
Is there a switch in the php.ini file or in apache that needs to be tripped so that it accepts all my thousands of legacy php tags?
Thank you, Cesarok got it, update php.ini as follows.
*php.ini becomes php.ini.rpmsave in PHP 5*
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On
Now it works!! Woohoo.Yeah its a strange thing to enforce if you ask me. I prefer <? short tags, but i like everything as compact as i can get it Before it is all over with you will find that using short tags might just work if you change your tags by merely adding php it is strongly suggested to make your code conform to this small change, and if you will notice alot of questions asked on these forums involve just this very use of short tags, I do not think that you have thousands of pages of code that use this method and if they do then stay where you are with your hosting and please don't share code that relies on it to work when <?php always will but <? might not keeping things short is lazy and in come cases harmful.
It is not good coding practice and should be discouraged. If you have any kind of editor at all a simple global search and replace should suffice to correct, but if you are that lazy then you get what you deserve by being lazy, like not testing for errors when running sql queries (while stating that it didn't give you one, of course it didn't if you didn't ask it to) then showing your shortcut code there is a lack of error checking sql included. I learned the hard way that unless it is a fatal error you won't see it even if your stupid query fails thanks to shortcuts.Haha, I was only joking really. I actually do trouble myself to push those 3 extra keys each time.
Oh how my fingers ache.I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags.
Now you say it.will not let the short tags get me alive. I will always use full tags.
"Feyd" from <!-- m --><a class="postlink" href="http://forums.devnetwork.net/viewtopic.php?p=261678#261678">http://forums.devnetwork.net/viewtopic. ... 678#261678</a><!-- m --> wrote -
It is best to alter all of your files to add the correct tags however. This can be done via a script or command-line fairly easily, although it does rely a bit on how you vary in the usage:
[feyd@home]> php -r "foreach(glob('*.php') as $file) { file_put_contents($file, preg_replace(array('#<\?\s*=#s', '#<\?(\s*)#s'), array('<?php echo ', '<?php$1'), file_get_contents($file))); }"
It may need a little tweaking depending on if I wrote it right (did it from memory) and based on how your write your code most often, but should work for most instances. Run that in each directory you have scripts in that use short tags.
Is there a switch in the php.ini file or in apache that needs to be tripped so that it accepts all my thousands of legacy php tags?
Thank you, Cesarok got it, update php.ini as follows.
*php.ini becomes php.ini.rpmsave in PHP 5*
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On
Now it works!! Woohoo.Yeah its a strange thing to enforce if you ask me. I prefer <? short tags, but i like everything as compact as i can get it Before it is all over with you will find that using short tags might just work if you change your tags by merely adding php it is strongly suggested to make your code conform to this small change, and if you will notice alot of questions asked on these forums involve just this very use of short tags, I do not think that you have thousands of pages of code that use this method and if they do then stay where you are with your hosting and please don't share code that relies on it to work when <?php always will but <? might not keeping things short is lazy and in come cases harmful.
It is not good coding practice and should be discouraged. If you have any kind of editor at all a simple global search and replace should suffice to correct, but if you are that lazy then you get what you deserve by being lazy, like not testing for errors when running sql queries (while stating that it didn't give you one, of course it didn't if you didn't ask it to) then showing your shortcut code there is a lack of error checking sql included. I learned the hard way that unless it is a fatal error you won't see it even if your stupid query fails thanks to shortcuts.Haha, I was only joking really. I actually do trouble myself to push those 3 extra keys each time.
Oh how my fingers ache.I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags. I will not let the short tags get me alive. I will always use full tags.
Now you say it.will not let the short tags get me alive. I will always use full tags.
"Feyd" from <!-- m --><a class="postlink" href="http://forums.devnetwork.net/viewtopic.php?p=261678#261678">http://forums.devnetwork.net/viewtopic. ... 678#261678</a><!-- m --> wrote -
It is best to alter all of your files to add the correct tags however. This can be done via a script or command-line fairly easily, although it does rely a bit on how you vary in the usage:
[feyd@home]> php -r "foreach(glob('*.php') as $file) { file_put_contents($file, preg_replace(array('#<\?\s*=#s', '#<\?(\s*)#s'), array('<?php echo ', '<?php$1'), file_get_contents($file))); }"
It may need a little tweaking depending on if I wrote it right (did it from memory) and based on how your write your code most often, but should work for most instances. Run that in each directory you have scripts in that use short tags.