3v4l.org

run code in 300+ PHP versions simultaneously
<?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 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<?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 5.6.0 - 5.6.40, 7.4.0 - 7.4.33
<?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.1.6, 5.2.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.3.11, 4.4.0 - 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.

preferences:
293.15 ms | 401 KiB | 459 Q