3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php <?php class Foo { public $bar = 'barValue'; protected $baz = 'bazValue'; private $biz = 'bizValue'; } $foo = new Foo(); $arrayFoo = (array) $foo; $out = var_export($arrayFoo, true); $out = preg_replace('/\'\' . "\\\0\" . \'[*a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\' . "\\\0\" . /', '', $out); $newArray = unvar_dump($out); var_dump($newArray); function unvar_dump($str) { if (strpos($str, "\n") === false) { //Add new lines: $regex = array( '#(\\[.*?\\]=>)#', '#(string\\(|int\\(|float\\(|array\\(|NULL|object\\(|})#', ); $str = preg_replace($regex, "\n\\1", $str); $str = trim($str); } $regex = array( '#^\\040*NULL\\040*$#m', '#^\\s*array\\((.*?)\\)\\s*{\\s*$#m', '#^\\s*string\\((.*?)\\)\\s*(.*?)$#m', '#^\\s*int\\((.*?)\\)\\s*$#m', '#^\\s*float\\((.*?)\\)\\s*$#m', '#^\\s*\[(\\d+)\\]\\s*=>\\s*$#m', '#\\s*?\\r?\\n\\s*#m', ); $replace = array( 'N', 'a:\\1:{', 's:\\1:\\2', 'i:\\1', 'd:\\1', 'i:\\1', ';' ); $serialized = preg_replace($regex, $replace, $str); $func = create_function( '$match', 'return "s:".strlen($match[1]).":\\"".$match[1]."\\"";' ); $serialized = preg_replace_callback( '#\\s*\\["(.*?)"\\]\\s*=>#', $func, $serialized ); $func = create_function( '$match', 'return "O:".strlen($match[1]).":\\"".$match[1]."\\":".$match[2].":{";' ); $serialized = preg_replace_callback( '#object\\((.*?)\\).*?\\((\\d+)\\)\\s*{\\s*;#', $func, $serialized ); $serialized = preg_replace( array('#};#', '#{;#'), array('}', '{'), $serialized ); return unserialize($serialized); } //"a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff"; // '' . "\0" . '*' . "\0" . //echo $out . PHP_EOL; //$b = serialize(array('bar' => 'barValue', 'baz' => 'bazValue', 'biz' => 'bizValue')); //echo $b . PHP_EOL;
Output for 5.3.0 - 5.4.17
Parse error: syntax error, unexpected '<' in /in/9HeHn on line 2
Process exited with code 255.