finding php5 code in my php code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ehogan
Forum Newbie
Posts: 3
Joined: Wed Dec 17, 2008 10:55 pm

finding php5 code in my php code

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: finding php5 code in my php code

Post 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.
ehogan
Forum Newbie
Posts: 3
Joined: Wed Dec 17, 2008 10:55 pm

Re: finding php5 code in my php code

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: finding php5 code in my php code

Post 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.
Post Reply