3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private function customErrorHandler(int $code, string $msg): bool { var_dump(preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg)); return true; } protected function write(): void { set_error_handler([$this, 'customErrorHandler']); try { $stream = fopen('logs://userfrosting.log', 'a'); trigger_error('Test test'); } finally { restore_error_handler(); } } public function test() { $this->write(); } } class Bar { public function customErrorHandler(int $code, string $msg): bool { var_dump(preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg)); return true; } protected function write(): void { set_error_handler([$this, 'customErrorHandler']); try { $stream = fopen('logs://userfrosting.log', 'a'); trigger_error('Test test'); } finally { restore_error_handler(); } } public function test() { $this->write(); } } class StreamHandler { public $context; public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool { $path = str_replace('logs://', '', $path); return @fopen($path, $mode); } } stream_wrapper_register('logs', StreamHandler::class); (new Bar)->test(); (new Foo)->test();
Output for git.master, git.master_jit, rfc.property-hooks
string(109) "open_basedir restriction in effect. File(userfrosting.log) is not within the allowed path(s): (/tmp:/in:/etc)" string(46) "Failed to open stream: Operation not permitted" string(63) "Failed to open stream: "StreamHandler::stream_open" call failed" string(9) "Test test" Fatal error: Uncaught Error: Invalid callback Foo::customErrorHandler, cannot access private method Foo::customErrorHandler() in /in/PjtpI:58 Stack trace: #0 /in/PjtpI(58): fopen('userfrosting.lo...', 'a') #1 [internal function]: StreamHandler->stream_open('userfrosting.lo...', 'a', 0, NULL) #2 /in/PjtpI(14): fopen('logs://userfros...', 'a') #3 /in/PjtpI(23): Foo->write() #4 /in/PjtpI(64): Foo->test() #5 {main} thrown in /in/PjtpI on line 58
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
26.53 ms | 406 KiB | 5 Q