Page 1 of 1
finding php5 code in my php code
Posted: Wed Dec 17, 2008 10:58 pm
by ehogan
Hello. I've developed some code on my webserver that i've installed with php5. Other folks that have picked up this code are running into bugs that i suspect are due to them running php4.
Is there an easy way to find the php5 specific code in my .php files? I imagine that I'm using some php5 specific syntax/function without realizing it.
Re: finding php5 code in my php code
Posted: Wed Dec 17, 2008 11:38 pm
by requinix
The biggest differences between 4 and 5 have to do with classes. For example, PHP 4 doesn't have access modifiers (public, private, protected), no model for interfaces, no magic methods (except for __sleep/wakeup)... The entire model was basically redone.
(There are some other features and functions added in 5 too.)
My opinion:
Don't cater to those people running PHP 4. It was killed off and isn't supported anymore. Tell them that if they want to use the code they need to upgrade.
If you don't like that, download PHP 4 and try your code, then (a) produce a PHP 4 specific version, or (b) ignore the future of the language and only write PHP 4 code.
Re: finding php5 code in my php code
Posted: Wed Dec 17, 2008 11:50 pm
by ehogan
It's not just classes though, even simple functions like:
Code: Select all
string stristr ( string $haystack , mixed $needle [, bool $before_needle ] )
the change log for the function says
5.3.0 Added the optional parameter before_needle .
I might using something that appears to be php4 compatible, but I may be unknowingly using it in a php5 way.
I am just trying to find some tool or some way to scan my code and say (for example) "look at line 17, the before_needle argument is not php4 compatible.
Re: finding php5 code in my php code
Posted: Thu Dec 18, 2008 12:03 am
by requinix
ehogan wrote:I am just trying to find some tool or some way to scan my code and say (for example) "look at line 17, the before_needle argument is not php4 compatible.
Pretty sure no such tool exists.
Like I said, download and install PHP 4, then go through the error messages you get and adjust the code.