3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Duplicates an array, even if the array contains * references. * * @param $arr array The array to duplicate. * @return array The duplicate of the array. */ function array_dup($arr) { $ret = []; foreach ($arr as $key => $value) $ret[$key] = $value; return $ret; } /** * Create an array of references to the elements of an array. * * @param $arr array The array to create references to. * @return array */ function refArray(&$arr) { $refs = []; foreach ($arr as $key => $value) $refs[$key] = &$arr[$key]; return $refs; } /** * Invokes a callback while capturing the output buffer * changes produced by it, and returns those changes as * a string. * * @param $callback callback The function to call. * @return string */ function captureOutputBuffer($callback) { ob_start(); $callback(); $dat = ob_get_contents(); if ($dat === false || ob_end_clean() !== true) throw new LogicException('ERROR: Something is wrong! Failed to retrieve the buffer\'s body!'); return $dat; } /** * Clean a partial page path of all invalid characters, * and ready it for lookup in the database. * * @param $path string The path to clean. * @return string A clean version of the path. */ function cleanPagePath($path) { $path = strtolower(rtrim($path, '/')); $tmp = ''; $pathLength = strlen($path); for ($i = 0; $i < $pathLength; $i++) { switch ($path[$i]) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '_': case '-': case '/': $tmp .= $path[$i]; continue; // Backslashes are looked up as forward slashes. case '\\': $tmp .= '/'; continue; // Spaces are replaced with underscores. case ' ': $tmp .= '_'; continue; default: continue; } } return $tmp; }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /in/LT8lL on line 106 Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /in/LT8lL on line 111 Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /in/LT8lL on line 116 Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /in/LT8lL on line 119

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:
50.74 ms | 402 KiB | 8 Q