3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'foo'; $replacement = 'bar'; $str1 = preg_replace_callback('/^foo$/', function($match) { global $replacement; return $replacement; }, $str); $str2 = preg_replace_callback('/^foo$/', function($match, &$replacement) { return $replacement; }, $str); var_dump($str1); var_dump($str2);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed and exactly 2 expected in /in/buOI7:12 Stack trace: #0 [internal function]: {closure}(Array) #1 /in/buOI7(12): preg_replace_callback('/^foo$/', Object(Closure), 'foo') #2 {main} thrown in /in/buOI7 on line 12
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:
39.45 ms | 401 KiB | 8 Q