3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<pre><?php print "\n"; $web=true; //output for HTML (true) or Console (false) class simobject{} $res2=imagecreate(1,1); $q=array($res2,NAN,INF,-INF,NULL,'',array(),'true','text',TRUE,1,1e0,'1',FALSE,'false','-','+',chr(0),0,'0',0e0,-1,-1e0,'-01','-001','01','001'); if ($web) $lt='&lt';else $lt='<'; if ($web) $gt='&gt';else $gt='>'; function prhead($spc){ global $lt,$gt; print "\n".str_pad('$a',$spc-1,' ',STR_PAD_BOTH).'VS.'.str_pad('$b',$spc-1,' ',STR_PAD_BOTH).' '; print '$a'.$gt.'$b'." ".'$a'.$lt.'$b'." ".'$a'.$lt.'=$b'." ".'$a'.$gt.'=$b'; print " ".'$a==$b'." ".'$a===$b'." \n"; } function prline($item,$spc){ print str_pad($item['typea'].'('.$item['vala'].')',$spc,' ',STR_PAD_BOTH).' '; print str_pad($item['typeb'].'('.$item['valb'].')',$spc,' ',STR_PAD_BOTH); unset($item['typea']);unset($item['typeb']); unset($item['vala']);unset($item['valb']);unset($item['a']);unset($item['b']); foreach ($item as $i) print ' '.str_pad($i,5,' ',STR_PAD_LEFT); print " \n"; } function prabc($item,$spc){ global $lt,$gt; print str_pad($item['typea'].'('.$item['vala'].') ',$spc,' ',STR_PAD_BOTH).$gt.' '; print str_pad($item['typeb'].'('.$item['valb'].') ',$spc,' ',STR_PAD_BOTH).$gt.' '; print str_pad($item['typec'].'('.$item['valc'].')',$spc,' ',STR_PAD_BOTH); print "\n"; } $wh=array('boolean','string','double','integer'); $to=array('bool','str','float','int'); $cleanup=array("'' . "," . ''","\n",'array ()'); $res=array();$crazy=array();$equality=array();$ltgt=array();$compatible=array();$greater=array(); $types=array();$vals=array(); foreach ($q as $a) { foreach ($q as $b) { $item=array(); $typea=str_replace($wh,$to,gettype($a));$types[$typea]=strlen($typea); $vala=str_replace($cleanup,'',var_export($a,true)); $vals[$vala]=strlen($vala); $typeb=str_replace($wh,$to,gettype($b));$types[$typeb]=strlen($typeb); $valb=str_replace($cleanup,'',var_export($b,true)); $vals[$valb]=strlen($valb); //if (($typea!=$typeb)||($vala!=$valb)){ $item['gt']=var_export($a>$b,true); $item['lt']=var_export($a<$b,true); $item['lte']=var_export($a<=$b,true); $item['gte']=var_export($a>=$b,true); $item['eq']=var_export($a==$b,true); $item['eqs']=var_export($a===$b,true); $same=$item; $item['a']=$a; $item['b']=$b; $item['typea']=$typea; $item['typeb']=$typeb; $item['vala']=$vala; $item['valb']=$valb; $head=array($typea.'('.$vala.')',$typeb.'('.$valb.')'); sort($head); $head=implode('',$head); //funny huh? if ($item['gt']=='true') $greater[]=$item; if (count(array_unique($same))==1) { if (!isset($crazy[$head])) $crazy[$head]=$item; } elseif ($item['eq']!=$item['eqs']) { if (!isset($equality[$head])) $equality[$head]=$item; } elseif (($item['eq']==$item['eqs'])&&($item['eq']=='true')) { if (!isset($compatible[$head])) $compatible[$head]=$item; } elseif (($item['lt']==$item['gt'])&&($item['gt']=='true')) { if (!isset($ltgt[$head])) $ltgt[$head]=$item; } else { if (!isset($res[$head])) $res[$head]=$item; } //} } } ksort($crazy); ksort($res); ksort($ltgt); ksort($equality); ksort($compatible); $spc=max($vals)+max($types)+2; /* print "Very strange: "; prhead($spc); foreach ($crazy as $item) prline($item,$spc); print "</pre>\n"; print "Equal but not identical: \n<pre>"; prhead($spc); foreach ($equality as $item) prline($item,$spc); print "</pre>\n"; print "Lower and Greater at the same time? \n<pre>"; prhead($spc); foreach ($ltgt as $item) prline($item,$spc); print "</pre>\n"; print "Lower or Greater: \n<pre>"; prhead($spc); foreach ($res as $item) prline($item,$spc); */ /* // Mostly A to A comparisons, strange for INF and -INF only print "Compatible (equal and identical): \n<pre>"; prhead($spc); foreach ($compatible as $item) prline($item,$spc); print "</pre>\n"; */ print "\n".'The "$a '.$gt.' $b '.$gt.' $c" --'.$gt.' "$a not '.$gt.' than $c" Conundrum'."\n"; $total=count($greater); print 'Total greater: '.$total."\n"; ?></pre>
Output for 7.0.0 - 7.1.0
<pre> Fatal error: Uncaught Error: Call to undefined function imagecreate() in /in/FSkl1:6 Stack trace: #0 {main} thrown in /in/FSkl1 on line 6
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
<pre> The "$a &gt $b &gt $c" --&gt "$a not &gt than $c" Conundrum Total greater: 267 </pre>
Output for 5.3.0 - 5.6.28
<pre> Fatal error: Call to undefined function imagecreate() in /in/FSkl1 on line 6
Process exited with code 255.