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); $str3 = preg_replace_callback('/^foo$/', function($match) use ($replacement) { return $replacement; }, $str); var_dump($str1); var_dump($str2); var_dump($str3);
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/F3ULn:12 Stack trace: #0 [internal function]: {closure}(Array) #1 /in/F3ULn(12): preg_replace_callback('/^foo$/', Object(Closure), 'foo') #2 {main} thrown in /in/F3ULn 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:
44.48 ms | 401 KiB | 8 Q