3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php header('Content-type: text/html; charset=UTF-8'); function verificaNumero( $numero = null) { if( !is_null( $numero ) && preg_match('/^((\d+)((\.|,)\d+)?)$/', $numero) ) { $numero = preg_replace('/,/sim', '.', $numero); echo $numero . PHP_EOL; } else echo 'Não passou' . PHP_EOL; } verificaNumero(10); verificaNumero(10.11); verificaNumero('10,12'); verificaNumero('String'); verificaNumero('a123');
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
10 10.11 10.12 Não passou Não passou
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/qfq7p on line 7 10PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/qfq7p on line 7 10.11PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/qfq7p on line 7 10.12PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/qfq7p on line 10 Não passouPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/qfq7p on line 10 Não passouPHP_EOL