viernes, 10 de marzo de 2017

ctype_digit() example Digits



<?php
$strings = array('1820.20', '10002', 'wsl!12');
foreach ($strings as $testcase) {
    if (ctype_digit($testcase)) {
        echo "The string $testcase consists of all digits.\n";
    } else {
        echo "The string $testcase does not consist of all digits.\n";
    }
}
?>



Example #2 A ctype_digit() example comparing strings with integers
<?php

$numeric_string 
'42';$integer        42;ctype_digit($numeric_string);  // true
ctype_digit($integer);         // false (ASCII 42 is the * character)is_numeric($numeric_string);   // trueis_numeric($integer);          // true?>

No hay comentarios:

Publicar un comentario