Jaaa
Jaaa

Reputation: 13

PHP 4- ignore parse errors?

I have a script that uses a PHP 5 syntax that's apparently not supported in PHP 4.

like MyClass::method()->method(...)

I'm trying to display a error at the beginning of the script telling that the server doesn't have PHP 5 installed, and "die" nicely, but I can't because I get that stupid parse error...

So how can I make PHP ignore errors if < 5 ?

Upvotes: 1

Views: 1005

Answers (4)

k102
k102

Reputation: 8079

if ((int)phpversion() < 5){
  error_reporting(0);
}

Upvotes: 0

lonesomeday
lonesomeday

Reputation: 237855

The easiest way I can think of is to have one file that includes another if PHP5 is installed:

//index.php
if (intval(substr(phpversion(), 0, 1)) < 5) {
    die ('you must have PHP 5 installed');
} else {
    include('main.php');
}

//main.php
MyClass::method()->method(); // or whatever

Upvotes: 5

lukas.pukenis
lukas.pukenis

Reputation: 13597

It can't ignore the errors, however it can die nicely if error_reporting(0);

Upvotes: 0

Related Questions