3v4l.org

run code in 300+ PHP versions simultaneously
<?php function debug($variable) { ob_start(); var_dump($variable); $output = ob_get_clean(); $maps = [ 'string' => "/(string\((?P<length>\d+)\)) (?P<value>\"(?<!\\\).*\")/i", 'array' => "/\[\"(?P<key>.+)\"(?:\:\"(?P<class>[a-z0-9_\\\]+)\")?(?:\:(?P<scope>public|protected|private))?\]=>/Ui", 'countable' => "/(?P<type>array|int|string)\((?P<count>\d+)\)/", 'resource' => "/resource\((?P<count>\d+)\) of type \((?P<class>[a-z0-9_\\\]+)\)/", 'bool' => "/bool\((?P<value>true|false)\)/", 'float' => "/float\((?P<value>[0-9\.]+)\)/", 'object' => "/object\((?P<class>\S+)\)\#(?P<id>\d+) \((?P<count>\d+)\)/i" ]; foreach ($maps as $function => $pattern) { $output = preg_replace_callback($pattern, function ($matches) use ($function) { switch ($function) { case 'string': $matches['value'] = htmlspecialchars($matches['value']); return '<span style="color: #0000FF;">string</span>(<span style="color: #1287DB;">' . $matches['length'] . ')</span> <span style="color: #6B6E6E;">' . $matches['value'] . '</span>'; case 'array': $key = '<span style="color: #008000;">"' . $matches['key'] . '"</span>'; $class = ''; $scope = ''; if (isset($matches['class']) && !empty($matches['class'])) { $class = ':<span style="color: #4D5D94;">"' . $matches['class'] . '"</span>'; } if (isset($matches['scope']) && !empty($matches['scope'])) { $scope = ':<span style="color: #666666;">' . $matches['scope'] . '</span>'; } return '[' . $key . $class . $scope . ']=>'; case 'countable': $type = '<span style="color: #0000FF;">' . $matches['type'] . '</span>'; $count = '(<span style="color: #1287DB;">' . $matches['count'] . '</span>)'; return $type . $count; case 'bool': return '<span style="color: #0000FF;">bool</span>(<span style="color: #0000FF;">' . $matches['value'] . '</span>)'; case 'float': return '<span style="color: #0000FF;">float</span>(<span style="color: #1287DB;">' . $matches['value'] . '</span>)'; case 'resource': return '<span style="color: #0000FF;">resource</span>(<span style="color: #1287DB;">' . $matches['count'] . '</span>) of type (<span style="color: #4D5D94;">' . $matches['class'] . '</span>)'; case 'object': return '<span style="color: #0000FF;">object</span>(<span style="color: #4D5D94;">' . $matches['class'] . '</span>)#' . $matches['id'] . ' (<span style="color: #1287DB;">' . $matches['count'] . '</span>)'; } }, $output); } $header = ''; list($debugfile) = debug_backtrace(); if (!empty($debugfile['file'])) { $header = '<h4 style="border-bottom:1px solid #bbb;font-weight:bold;margin:0 0 10px 0;padding:3px 0 10px 0">' . $debugfile['file'] . '</h4>'; } echo '<pre style="background-color: #CDDCF4;border: 1px solid #bbb;border-radius: 4px;-moz-border-radius:4px;-webkit-border-radius\:4px;font-size:12px;line-height:1.4em;margin:30px;padding:7px">' . $header . $output . '</pre>'; } debug(['foo', 'bar', 'baz', 42]);
Output for git.master, git.master_jit, rfc.property-hooks
<pre style="background-color: #CDDCF4;border: 1px solid #bbb;border-radius: 4px;-moz-border-radius:4px;-webkit-border-radius\:4px;font-size:12px;line-height:1.4em;margin:30px;padding:7px"><h4 style="border-bottom:1px solid #bbb;font-weight:bold;margin:0 0 10px 0;padding:3px 0 10px 0">/in/iupYJ</h4><span style="color: #0000FF;">array</span>(<span style="color: #1287DB;">4</span>) { [0]=> <span style="color: #0000FF;">string</span>(<span style="color: #1287DB;">3)</span> <span style="color: #6B6E6E;">&quot;foo&quot;</span> [1]=> <span style="color: #0000FF;">string</span>(<span style="color: #1287DB;">3)</span> <span style="color: #6B6E6E;">&quot;bar&quot;</span> [2]=> <span style="color: #0000FF;">string</span>(<span style="color: #1287DB;">3)</span> <span style="color: #6B6E6E;">&quot;baz&quot;</span> [3]=> <span style="color: #0000FF;">int</span>(<span style="color: #1287DB;">42</span>) } </pre>

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:
55.08 ms | 403 KiB | 8 Q