3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class User { public function getZipCode($value) { return $value; } } $user = new User(); if (preg_match("/^[0-9]+$/",$user->getZipCode('489756'))) { $data['str'] = $user->getZipCode('489756'); } if (preg_match("/^[0-9]+$/",$user->getZipCode(489756))) { $data['int'] = $user->getZipCode(489756); } if (preg_match("/^[0-9]+$/",$user->getZipCode('489756d'))) { $data['badStr1'] = $user->getZipCode('489756d'); } if (preg_match("/^[0-9]+$/",$user->getZipCode(NULL))) { $data['null'] = $user->getZipCode(NULL); } var_dump($data);
based on 0R3lH
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0beta1
array(2) { ["str"]=> string(6) "489756" ["int"]=> int(489756) }
Output for hhvm-3.12.14 - 3.17.3
Warning: preg_match() expects parameter 2 to be string, null given in /in/drroH on line 21 array(2) { ["str"]=> string(6) "489756" ["int"]=> int(489756) }