- version_compare: documentation ( source)
<?php
class MyException extends Exception
{
public function __construct($message, $code=0, Exception $previous = null)
{
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
parent::__construct($message,$code,$previous);
}
else {
parent::__construct($message,$code);
}
}
public function __toString() {
return __CLASS__. ":[{$this->code}]:{$this->message}\n";
}
}
throw new MyException("Foo");