I want to catch this error:
$a[1] = 'jfksjfks';
try {
$b = $a[0];
} catch (\Exception $e) {
echo "jsdlkjflsjfkjl";
}
Edit: in fact, I got this error on the following line:
$parse = $xml->children[0]->children[0]->toArray();
I want to catch this error:
$a[1] = 'jfksjfks';
try {
$b = $a[0];
} catch (\Exception $e) {
echo "jsdlkjflsjfkjl";
}
Edit: in fact, I got this error on the following line:
$parse = $xml->children[0]->children[0]->toArray();
You can't with a try/catch block, as this is an error, not an exception.
Always tries offsets before using them:
I know it's 2016 but in case someone gets to this post.
You could use the
array_key_exists($index, $array)
method in order to avoid the exception to happen.Or, without the inefficiency of creating a very temporary exception:
Im sure why the Error Throw but i fix some..
in html2pdf.class.php
on Lines 2132:
SAME On line 2138:
the problem the array $sw not have a key of $corr[$y][$x][2] so i fix the loop for to max count($sw) to fix .. I dont know if that create an another consecuense but i resolve my problem y dont have any more errors..
So i hope works to you ..!!! Beats Reguards
You need to define your custom error handler like:
Normally, you can't catch notices with try-catch block. But you can convert notices to exceptions! Use this way:
Also, you can use this function for to catch warnings. Just change function name to get_warning and change
"<b>Notice</b>:"
to"<b>Warning</b>:"
.Note: The function will catch an innocent output that contains:
<b>Notice</b>:
But to escape from this problem, simply, change it to:
<b>Notice:</b>