3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function isString($value) { return is_string($value); } $vBase = [ 'date' => function($value) { return (bool)preg_match('/^\d{2}\.\d{2}\.\d{4}$/', $value); }, 'string' => isString, ]; $dateVal[] = date('d.m.Y'); $dateVal[] = date('Y-m-d'); foreach ($dateVal as $date) { var_dump( [ 'value' => $date, 'isValidFormat' => $vBase['date']($date), ] ); } var_dump( [ 'value' => 'Nikita' 'isValidString' => $vBase['string']('Nikita'), ], [ 'value' => 1, 'isValidString' => $vBase['string'](1) ] );
Output for 5.4.0 - 5.4.15
Parse error: syntax error, unexpected ''isValidString'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in /in/4LnKg on line 29
Process exited with code 255.
Output for 5.3.25
Parse error: syntax error, unexpected '[' in /in/OqiOt on line 7
Process exited with code 255.
Output for 5.3.0 - 5.3.24
Parse error: syntax error, unexpected '[' in /in/4LnKg on line 7
Process exited with code 255.