- var_dump: documentation ( source)
- phpversion: documentation ( source)
- set_error_handler: documentation ( source)
- test1: documentation ( source)
<?php
declare(strict_types = 1);
phpversion() >= "7.0.0" or die();
function myErrorHandler($errno, $errstr, $errfile, $errline) {
if ( E_RECOVERABLE_ERROR===$errno ) {
echo "'catched' catchable fatal error\n";
return true;
}
return false;
}
set_error_handler('myErrorHandler');
class FooBar {
public $prop = '123';
}
class BarFoo {
public $prop = '312';
}
function test () : FooBar {
return new FooBar;
}
function test1 () : BarFoo {
return new FooBar;
}
try {
var_dump(test1());
} catch (Exception $e) {
var_dump($e->getMessage());
}
var_dump(test());