3v4l.org

run code in 300+ PHP versions simultaneously
<?php class customException extends Exception { public function errorMessage() { $errorMsg = 'error on line ' .$this->getLine(). ' in '.$this->getFle().': <b>' .$this->geMessage().'</b> is not a valid e-mail address'; return $errorMsg; } } $emial = "someone@example.com"; try { if(filter_var($email, FILTER_VALIDATE_EMAIL) === false) { throw new customException($emial); } if(strpos($email,"example") !== FALSE) { throw new Exception("emial is an example e-mail"); } } catch (customException $e) { echo $e->errorMessage(); } catch(Excception $e) { echo $e->getMessage(); } ?>

preferences:
53.29 ms | 402 KiB | 5 Q