3v4l.org

run code in 300+ PHP versions simultaneously
<?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> >$end
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Parse error: Unclosed '{' on line 102 in /in/AInUv on line 114
Process exited with code 255.
Output for 8.0.13
<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/AInUv" onsubmit="return s();"> <table border=all><col align=center><col align=left> Warning: fopen(count.txt): Failed to open stream: Read-only file system in /in/AInUv on line 12 Fatal error: Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, bool given in /in/AInUv:12 Stack trace: #0 /in/AInUv(12): fwrite(false, '0') #1 /in/AInUv(106): MyCount() #2 {main} thrown in /in/AInUv on line 12
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.33
<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/AInUv" onsubmit="return s();"> <table border=all><col align=center><col align=left> Warning: fopen(count.txt): failed to open stream: Read-only file system in /in/AInUv on line 12 Warning: fwrite() expects parameter 1 to be resource, bool given in /in/AInUv on line 12 Warning: fclose() expects parameter 1 to be resource, bool given in /in/AInUv on line 12 Warning: file_get_contents(count.txt): failed to open stream: No such file or directory in /in/AInUv on line 13 Warning: fopen(count.txt): failed to open stream: No such file or directory in /in/AInUv on line 15 Warning: flock() expects parameter 1 to be resource, bool given in /in/AInUv on line 16 Warning: fputs() expects parameter 1 to be resource, bool given in /in/AInUv on line 17 Warning: fclose() expects parameter 1 to be resource, bool given in /in/AInUv 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> >$end
Output for 7.1.26 - 7.1.33, 7.2.17 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
Parse error: syntax error, unexpected end of file in /in/AInUv on line 114
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
<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/AInUv" onsubmit="return s();"> <table border=all><col align=center><col align=left> Warning: fopen(count.txt): failed to open stream: Permission denied in /in/AInUv on line 12 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/AInUv on line 12 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/AInUv on line 12 Warning: file_get_contents(count.txt): failed to open stream: No such file or directory in /in/AInUv on line 13 Warning: fopen(count.txt): failed to open stream: No such file or directory in /in/AInUv on line 15 Warning: flock() expects parameter 1 to be resource, boolean given in /in/AInUv on line 16 Warning: fputs() expects parameter 1 to be resource, boolean given in /in/AInUv on line 17 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/AInUv 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> >$end
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected $end in /in/AInUv on line 114
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 $ in /in/AInUv on line 114
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/AInUv on line 114
Process exited with code 255.

preferences:
303.62 ms | 401 KiB | 377 Q