How to try-cach in php 7. I’m using Yii 2 and php 7.0.33
with code:
try {
$value = 1 % 0;
} catch (Throwable $e) {
echo “ERROR”;
}
It does not work
How to try-cach in php 7. I’m using Yii 2 and php 7.0.33
with code:
try {
$value = 1 % 0;
} catch (Throwable $e) {
echo “ERROR”;
}
It does not work
It works on all PHP versions >= 7.0 of course assuming Throwable
is in fact \Throwable
and quotes for echo are proper PHP quotes.
Hi @itlvk, welcome to the forum.
The following code ("\Throwable"
instead of "Throwable"
) worked for me:
public function actionIndex()
{
try {
$value = 1 % 0;
} catch (\Throwable $e) {
echo "ERROR\n";
}
...
PHP 7.2.3 / Yii 2.0.16.1
thanks, it’s work fine