3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ErrorReportingSwitcher { private $old_flags; public function __construct( $flag_add, $flag_remove = 0 ) { echo __METHOD__ . PHP_EOL; $this->old_flags = error_reporting(); $new_flags = $this->old_flags; if ( $flag_add != 0 ){ $new_flags |= $flag_add; } if ( $flag_remove != 0 ){ $new_flags &= ~$flag_remove; } error_reporting($new_flags); } public function __destruct() { echo __METHOD__ . PHP_EOL; if ( $this->old_flags ){ error_reporting( $this->old_flags ); } } } function hoge() { echo "start\n"; $_ = new ErrorReportingSwitcher(0,E_STRICT); // strict warningが発生する処理 echo "end\n"; } hoge();

preferences:
39.47 ms | 402 KiB | 5 Q