Gracefull say no to PHP4

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
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Gracefull say no to PHP4

Post by greyhoundcode »

Is there some way of checking if a script is running under PHP 5, and if not to gracefully display an appropriate error message, "Sorry mate, this script doesn't run on PHP 4."
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Gracefull say no to PHP4

Post by requinix »

User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Gracefull say no to PHP4

Post by greyhoundcode »

Simple as that eh? I did a little searching and kept getting bumf about phpinfo(), which wasn't what I wanted. Thanks Tazza, owe you a notional beer.

Code: Select all

phpversion();
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Gracefull say no to PHP4

Post by requinix »

In case you didn't notice, there's also the PHP_VERSION constant. Same thing as phpversion(), no function call.
And there's version_compare, of course.
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Gracefull say no to PHP4

Post by greyhoundcode »

Yeah I was aware of version_compare(), but PHP_VERSION and phpversion() had eluded me.
Post Reply