3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function checkPositiveInt($var) { if (is_numeric($var)) { if (is_int($var)) { if ($var > 0) { return true; } } } return false; } $devidL = '05.08.2017'; $arrayInputsState['devid'] = ''; if ($devidL != '') { $arrayDate = explode(".", $devidL); $numberOfValid = 0; if (checkPositiveInt($arrayDate[0])) { $day = (int)$arrayDate[0]; ++$numberOfValid; } if (checkPositiveInt($arrayDate[1])) { $month = (int)$arrayDate[1]; ++$numberOfValid; } if (checkPositiveInt($arrayDate[2])) { $year = (int)$arrayDate[2]; ++$numberOfValid; } if ($numberOfValid == 3) { if (checkdate($month, $day, $year)) { $date = \DateTime::createFromFormat('d.m.Y', $devidL); if ($date) { $Zaznam->setDEVID($date); $arrayInputsState['devid'] = 'ok'; } else { $arrayInputsState['devid'] = 'error'; } } else { $arrayInputsState['devid'] = 'error'; } } } else { $arrayInputsState['devid'] = 'empty'; } echo 'vysledok je <br>'; var_dump($arrayInputsState['devid']);
based on HsqCN
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0rc3
vysledok je <br>string(0) ""