3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if (isset($_POST['id'])) $id=stripslashes($_POST['id']); else { if (isset($_GET['id'])) $id=stripslashes($_GET['id']); else $id=""; } if (isset($_POST['cmd'])) $cmd=stripslashes($_POST['cmd']); else { if (isset($_GET['cmd'])) $cmd=stripslashes($_GET['cmd']); else $cmd=1; } function ahex2bin($s,$l) { for ($i = 0; $i < $l*2; $i += 2) { if($i < strlen($s)) $bin .= chr(hexdec(substr($s,$i,2))); else $bin .= chr(0); } return $bin; } $fp = fsockopen("udp://127.0.0.1", 80, $errno, $errstr); if (!$fp) { $answer="ERROR: $errno - $errstr<br>"; } else { $cmd = chr(0xfc).chr($cmd); $cmd = $cmd.ahex2bin($id,6).chr(0).chr(0).chr(0).chr(0).$data; if(fwrite($fp, $cmd)===FALSE) $answer="ERROR: write<br>"; else $answer="OK<br>"; fclose($fp); } echo $answer; ?>
Output for 5.4.42 - 7.2.0
Notice: Undefined variable: bin in /in/e1kn9 on line 30 Notice: Undefined variable: data in /in/e1kn9 on line 44 OK<br>
Output for 5.0.0 - 5.4.41
Warning: fsockopen(): unable to connect to udp://127.0.0.1:80 (Network is unreachable) in /in/e1kn9 on line 35 ERROR: 101 - Network is unreachable<br>
Output for 4.3.3 - 4.4.9
Warning: fsockopen(): unable to connect to 127.0.0.1:80 in /in/e1kn9 on line 35 ERROR: 101 - Network is unreachable<br>
Output for 4.3.2
Warning: fsockopen(): php_hostconnect: connect failed in /in/e1kn9 on line 35 Warning: fsockopen(): unable to connect to 127.0.0.1:80 in /in/e1kn9 on line 35 ERROR: 101 - Network is unreachable<br>
Output for 4.3.0 - 4.3.1

Process exited with code 139.