Before php 7 you could only catch exceptions, not errors, but since php 7 you have a new interface called \Throwable that is more general than just exceptions and also the Error class was introduced that implements Throwable
http://php.net/manual/en/class.throwable.php
There are currently two types of Throwable objects, that is Exceptions and Errors,
So now you can also catch Errors,
However Fatal errors still break your code
you can try
<?php
try
{
session_start();
echo ($counter);
}
catch(\Exception $e)
{
echo "caught exception";
}
catch(\Error $e)
{
echo "caught error";
}
or you car try
try
{
session_start();
echo ($counter);
}
catch(\Throwable $e)
{
echo "caught exception";
}