3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $DoB1 = '14/01/02'; $DoB1match = preg_match("/([0-2]\d|3[0-1])\/(0\d|1[0-2])\/\d{2}/", $DoB1); // Check pattern $age1 = DateTime::createFromFormat('d/m/y', $DoB1) ->diff(new DateTime('now')) ->y; // Check age $age1OK = $age1 > 4 && $age1 < 14; // Check age greater than 4 but less than 14 $DoB1Valid = $DoB1match && $age1OK; if ($age1OK == true) { echo 'yeah'; } else { echo 'nah'; }
based on BKJGH
Output for 5.3.18 - 5.4.45, 5.6.28, 7.0.20 - 7.2.0
yeah
Output for 5.5.24 - 5.6.21, 7.0.0 - 7.0.6
nah