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, Cesar
<?php ... ?> vs. <? ... ?> error
Moderator: General Moderators
-
empiresolutions
- Forum Newbie
- Posts: 20
- Joined: Tue Apr 11, 2006 10:39 am
- Location: Portland, Or
-
empiresolutions
- Forum Newbie
- Posts: 20
- Joined: Tue Apr 11, 2006 10:39 am
- Location: Portland, Or
ok 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.
*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.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
short_tags which is a php.ini directive.
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: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.
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:
Code: Select all
[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))); }"-
empiresolutions
- Forum Newbie
- Posts: 20
- Joined: Tue Apr 11, 2006 10:39 am
- Location: Portland, Or
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
The version I posted is intended for the command line.
As for "how you vary in the usage," what I mean is how you write the short tags. There are multiple ways to write the short tags, some are far more common than others. Examples of the common ways:The code I posted is intended for the common ways.
As for "how you vary in the usage," what I mean is how you write the short tags. There are multiple ways to write the short tags, some are far more common than others. Examples of the common ways:
Code: Select all
<? ... ?>
<?= ... ?>- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
interesting script ! I have been using search and replace tool to do that till now like regexxer in linux.feyd wrote:short_tags which is a php.ini directive.
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: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.Code: Select all
[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))); }"
Thank you for the simple mechanism feyd !
Cheers,
Dibyendra