3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $ip = '192.168.0.1'; $octets = explode('.', $ip); foreach($octets as $key => $octet) { $v = 255 - (int)$octet; ($v + 255 == 255) ? $valid = true : $valid = false; echo $v . PHP_EOL; if ($valid) echo 'valid'; else echo 'invalid'; echo PHP_EOL; } var_dump($octets);
based on YKsV6
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.1.0
63 invalid 87 invalid 255 invalid 254 invalid array(4) { [0]=> string(3) "192" [1]=> string(3) "168" [2]=> string(1) "0" [3]=> string(1) "1" }
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/v2qhT on line 11 63PHP_EOLinvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/v2qhT on line 18 PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/v2qhT on line 11 87PHP_EOLinvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/v2qhT on line 18 PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/v2qhT on line 11 255PHP_EOLinvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/v2qhT on line 18 PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/v2qhT on line 11 254PHP_EOLinvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/v2qhT on line 18 PHP_EOLarray(4) { [0]=> string(3) "192" [1]=> string(3) "168" [2]=> string(1) "0" [3]=> string(1) "1" }