Skip to content

Instantly share code, notes, and snippets.

@ggirtsou
Last active February 21, 2016 21:08
Show Gist options
  • Save ggirtsou/ee09a5a053e0d17e8caa to your computer and use it in GitHub Desktop.
Save ggirtsou/ee09a5a053e0d17e8caa to your computer and use it in GitHub Desktop.
catch (Exception $e) is executed only in PHP 5.x, will not be reached in PHP 7, read: https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
class MyObject {
public function getMyObject() : MyObject
{
return null;
}
}
try
{
$class = new MyObject();
$class->getMyObject();
}
catch(Throwable $e)
{
// Catch the exception
echo 'catched';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment