3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function minimize($file) { return preg_replace('#(<\?php)\s+#S','$1 ',preg_replace('#\s*([(){}[\];,.:+<>*/%^=&?|$-])\s*#S', '$1', array_reduce(token_get_all(php_strip_whitespace($file)),function($c,$x){ static $s = [], $i=0; if ( is_string($x) ) return $c . $x; $_ = $x[1]; if ( $x[0] == 310 ) return $c . (defined($_) ? (is_bool($k=constant($_))||is_null($k)?$_:$k) : $_); if ( $x[0] == 312 ) return $c . (empty($s[$_]) ? ($s[$_] = '$_' . base_convert($i++,10,36)) : $s[$_]); if ( $x[0] == 263 ) return $c . '||'; if ( $x[0] == 265 ) return $c . '&&'; return $c . $_; }))); } echo minimize(__FILE__);
based on Tf6nq
Output for 5.4.0 - 5.5.35, hhvm-3.12.0, 7.0.0 - 7.1.0
<?php function minimize($file){return preg_replace('#(<\?php)\s+#S','$1 ',preg_replace('#\s*([(){}[\];,.:+<>*/%^=&?|$-])\s*#S','$1',array_reduce(token_get_all(php_strip_whitespace($file)),function($c,$x){static$s=[],$i=0;if(is_string($x))return$c.$x;$_=$x[1];if($x[0]==310)return$c.(defined($_)?(is_bool($k=constant($_))||is_null($k)?$_:$k):$_);if($x[0]==312)return$c.(empty($s[$_])?($s[$_]='$_'.base_convert($i++,10,36)):$s[$_]);if($x[0]==263)return$c.'||';if($x[0]==265)return$c.'&&';return$c.$_;})));}echo minimize(__FILE__);
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.7 - 5.6.28
<?php function minimize($_0){return preg_replace('#(<\?php)\s+#S','$1 ',preg_replace('#\s*([(){}[\];,.:+<>*/%^=&?|$-])\s*#S','$1',array_reduce(token_get_all(php_strip_whitespace($_0)),function($_1,$_2){static$_3=[],$_4=0;if(is_string($_2))return$_1.$_2;$_5=$_2[1];if($_2[0]==310)return$_1.(defined($_5)?(is_bool($_6=constant($_5))||is_null($_6)?$_5:$_6):$_5);if($_2[0]==312)return$_1.(empty($_3[$_5])?($_3[$_5]='$_'.base_convert($_4++,10,36)):$_3[$_5]);if($_2[0]==263)return$_1.'||';if($_2[0]==265)return$_1.'&&';return$_1.$_5;})));}echo minimize(__FILE__);
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/4f0Gi on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/4f0Gi on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/4f0Gi on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/4f0Gi on line 5
Process exited with code 255.