<?php namespace Foo; class StreamHandler { public $errorMessage; public function __construct() { $this->errorMessage = null; set_error_handler([$this, 'customErrorHandler']); $stream = fopen('c:/fososdfsdfsd', 'a'); restore_error_handler(); } private function customErrorHandler(int $code, string $msg): bool { $this->errorMessage = preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg); return true; } } function fopen() { throw new \Exception(); } try{ $f = new StreamHandler; var_dump($f->errorMessage); }catch (\Throwable){ } $a = []; var_dump($a[1]);
You have javascript disabled. You will not be able to edit any code.