PHP 5.3 Upgrade causes scripts to fail

zardiw

Perch
When I upgrade my server to 5.3........none of my scripts work anymore......

Is there a cheat sheet or something that lists the changes that have to be made????????


z
 
We have your ticket related to this problem. We will update you through ticket soon.
 
Yes.....was hoping to get information here.....

I have SOLVED the problem.....

Under 5.2 it was sufficient to start PHP code with: <?

5.3 is a bit stupider than 5.2 was.......because you NEED to start PHP code with: <?php

Who woulda thought..........it was only because of my YEARS of programming experience that the Great Programming GODS whispered in my ear that that very thing was what was wrong.....


z
 
A more detailed explanation.....with a TIP.......for enquiring minds:

PHP tags

When PHP parses a file, it looks for opening and closing tags, which are <?php and ?> which tell PHP to start and stop interpreting the code between them. Parsing in this manner allows PHP to be embedded in all sorts of different documents, as everything outside of a pair of opening and closing tags is ignored by the PHP parser.

PHP also allows for short tags <? and ?> (which are discouraged because they are only available if enabled with short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option.

If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.
<?php
echo "Hello world";

// ... more code

echo "Last statement";

// the script ends here with no PHP closing tag



add a noteUser Contributed Notes PHP tags - [1 notes]
up
down
1
akshay dot leadindia at gmail dot com8 months ago
If you do (accidentally) leave out a newline character after the closing php tag ( '?>' ) then you may see 'Headers Already Sent' errors. So if you are seeing this error in your output, double check the php file for newline characters after the closing tag.
 
NOW the question becomes:

1. I change every one of my close to 100 scripts to change <? to <?php
OR
2. If I am able to set that flag:

short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option.

Perhaps Jodohost can offer some guidance

z
 
Just as a FTI short tags have been disabled by default for security purposes in the distributed PHP for some years now. I'll let the linux guys help you overall, but I do know this as it is noted in the example file.
 
Just as a FTI short tags have been disabled by default for security purposes in the distributed PHP for some years now. I'll let the linux guys help you overall, but I do know this as it is noted in the example file.

1. Well, it's all been working on 5.2.17 for years now.
2. What example file? What is FTI?
3. PHP is universal......Windows or Linux. I'm assuming there is some kind of config file on the Windows side.

And last but not least.......just changing <? to <?php is insufficient BECAUSE

You now need a space behind the <?php.

Before you were able to do: <?If a=b.....etc..... Now you have to do <?php If a=b.....etc

So the interpreter has changed also........it needs a space after the <?php..........what a royal PITA

z
 
Yes, short_open_tag is on now with PHP 5.3 through .htaccess. Now your domain is running with PHP 5.3.
 
Back
Top