3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $links = array ('http://yandex.ru/','http://google.com/','http://rambler.ru','http://www.mail.ru/','http://yahoo.com/', 'http://msn.com/','http://www.yellowpages.ru/', 'http://www.liveinternet.ru/', 'http://www.lenta.ru/','http://www.3.org/' ); function MyCount() { global $links; $file='count.txt'; if(!file_exists($file)){$fp = fopen($file, "w");fwrite($fp,'0');fclose($fp);} $k=(int)file_get_contents($file); $z=$k+1; $countf=fopen($file,"r+"); flock($countf,2); fputs($countf,$z); fclose($countf); $z=($k % count($links)); if ($z==0){$z=count($links);}else {$z=$z-1;} return $z; } function MyList($k) { global $links; $z= count($links)-$k; if ($z<5) { $links2=array_slice($links,($k),$z,true)+array_slice($links,0,(5-$z),true); } else { $links2=array_slice($links,$k,5,true); } return $links2; } function MyListToHTML($list) { $out=''; foreach ($list as $key => $value) { $key2=$key+1; $out.='<tr><th><input id="'.$key2.'" name="'.$key.'" type=checkbox><th><label for="'.$key2.'">'.$value.'</label></tr>'; } return $out; } ?> <html> <head> <script type="text/javascript"> var x;var y; function t(i){return (i<10)?"0"+i:i;} function z(){ var e = new Date(); window.status=t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+" x= "+x+", y= "+y; setTimeout('z()',1); } document.onmousemove=function(){x=event.x;y=event.y;} function s(){ var k=false; var nodeList = document.getElementsByTagName('input'); for (var i = 0; i < nodeList.length; i++) { if(nodeList[i].getAttribute("type") =="checkbox") { if (nodeList[i].checked==true) { k=true; } } } if(!k){alert('Ничего не выбрано');} return k; } </script></head> <body onLoad="z()"> <?php if(isset($_POST['submitMe'])) { echo("Вами были выбраны следующие ссылки:<br>"); foreach ($_POST as $key => $value) { if ($value=='on') echo '<a href="'.$links[$key].'">'.$links[$key].'</a><br>'; } } else { ?> <form name='MyList' method="POST" action="<?=$_SERVER['PHP_SELF']?>" onsubmit="return s();"> <table border=all><col align=center><col align=left> <?php echo MyListToHTML(Mylist(MyCount()));; ?> <tr><th>&nbsp;<th><input type=submit name="submitMe" value="Oк" style="width:200px;"></tr> </table> </form> <? } ?> </body></html> ?>
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
<html> <head> <script type="text/javascript"> var x;var y; function t(i){return (i<10)?"0"+i:i;} function z(){ var e = new Date(); window.status=t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+" x= "+x+", y= "+y; setTimeout('z()',1); } document.onmousemove=function(){x=event.x;y=event.y;} function s(){ var k=false; var nodeList = document.getElementsByTagName('input'); for (var i = 0; i < nodeList.length; i++) { if(nodeList[i].getAttribute("type") =="checkbox") { if (nodeList[i].checked==true) { k=true; } } } if(!k){alert('Ничего не выбрано');} return k; } </script></head> <body onLoad="z()"> <form name='MyList' method="POST" action="/in/bfcaC" onsubmit="return s();"> <table border=all><col align=center><col align=left> Warning: fopen(count.txt): failed to open stream: Permission denied in /in/bfcaC on line 12 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 12 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 12 Warning: file_get_contents(count.txt): failed to open stream: No such file or directory in /in/bfcaC on line 13 Warning: fopen(count.txt): failed to open stream: No such file or directory in /in/bfcaC on line 15 Warning: flock() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 16 Warning: fputs() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 17 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 18 <tr><th><input id="1" name="0" type=checkbox><th><label for="1">http://yandex.ru/</label></tr><tr><th><input id="2" name="1" type=checkbox><th><label for="2">http://google.com/</label></tr><tr><th><input id="3" name="2" type=checkbox><th><label for="3">http://rambler.ru</label></tr><tr><th><input id="4" name="3" type=checkbox><th><label for="4">http://www.mail.ru/</label></tr><tr><th><input id="5" name="4" type=checkbox><th><label for="5">http://yahoo.com/</label></tr><tr><th>&nbsp;<th><input type=submit name="submitMe" value="Oк" style="width:200px;"></tr> </table> </form> </body></html> ?>
Output for hhvm-3.10.0 - 3.12.0
<html> <head> <script type="text/javascript"> var x;var y; function t(i){return (i<10)?"0"+i:i;} function z(){ var e = new Date(); window.status=t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+" x= "+x+", y= "+y; setTimeout('z()',1); } document.onmousemove=function(){x=event.x;y=event.y;} function s(){ var k=false; var nodeList = document.getElementsByTagName('input'); for (var i = 0; i < nodeList.length; i++) { if(nodeList[i].getAttribute("type") =="checkbox") { if (nodeList[i].checked==true) { k=true; } } } if(!k){alert('Ничего не выбрано');} return k; } </script></head> <body onLoad="z()"> <form name='MyList' method="POST" action="/in/bfcaC" onsubmit="return s();"> <table border=all><col align=center><col align=left> Warning: Permission denied in /in/bfcaC on line 12 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 12 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 12 Warning: No such file or directory in /in/bfcaC on line 13 Warning: No such file or directory in /in/bfcaC on line 15 Warning: flock() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 16 Warning: fputs() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 17 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/bfcaC on line 18 <tr><th><input id="1" name="0" type=checkbox><th><label for="1">http://yandex.ru/</label></tr><tr><th><input id="2" name="1" type=checkbox><th><label for="2">http://google.com/</label></tr><tr><th><input id="3" name="2" type=checkbox><th><label for="3">http://rambler.ru</label></tr><tr><th><input id="4" name="3" type=checkbox><th><label for="4">http://www.mail.ru/</label></tr><tr><th><input id="5" name="4" type=checkbox><th><label for="5">http://yahoo.com/</label></tr><tr><th>&nbsp;<th><input type=submit name="submitMe" value="Oк" style="width:200px;"></tr> </table> </form> </body></html> ?>
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected $end in /in/bfcaC on line 114
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 $ in /in/bfcaC on line 114
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/bfcaC on line 114
Process exited with code 255.