function validateInput(&$errors)
{
    global $input;
    if (!isRequired($input) || !isNumeric($input)) {
        $errors['input'][] = 'You must enter a number.';
    }
    return empty($errors);
}
Beispiel #2
0
 public function writeIni($array, $file)
 {
     $res = array();
     foreach ($array as $key => $val) {
         if (is_array($val)) {
             $res[] = "[{$key}]";
             foreach ($val as $skey => $sval) {
                 $res[] = "{$skey} = " . (isNumeric($sval) ? $sval : '"' . $sval . '"');
             }
         } else {
             $res[] = "{$key} = " . (isNumeric($val) ? $val : '"' . $val . '"');
         }
     }
     safefilerewrite($file, implode("\r\n", $res));
 }
Beispiel #3
0
    global $error;
    if (!is_numeric($feet)) {
        $error = "El valor de los pies no es un número.";
        return false;
    } elseif (!is_numeric($inches)) {
        $error = "El valor de las pulgadas no es un número.";
        return false;
    } else {
        return true;
    }
}
if (isset($_REQUEST["submit"])) {
    if (isset($_REQUEST["feet"]) && isset($_REQUEST["inches"])) {
        $feet = $_REQUEST["feet"];
        $inches = $_REQUEST["inches"];
        if (isNumeric($feet, $inches)) {
            $centimetres = ($inches + $feet * 12) * 2.54;
        }
    }
}
?>
        <h2>Conversión de pies y pulgadas a metros</h2>
        <form action="ejercicio2.3.php" method="post">
            <table>
                <tr>
                    <td>Pies</td>
                    <td>
                        <input type="text" name="feet" value="0.0" />
                    </td>
                </tr>
                <tr>
Beispiel #4
0
<?php

//Write a PHP script DumpVariable.php that declares a variable. If the variable is numeric, print it by the built-in function var_dump(). If the variable is not numeric, print its type at the input.
function isNumeric($var)
{
    if (is_numeric($var)) {
        var_dump($var);
    } else {
        echo gettype($var) . "\n";
    }
}
isNumeric('hello');
isNumeric(15);
isNumeric(1.234);
isNumeric(array(1, 2, 3));
isNumeric((object) [2, 34]);
Beispiel #5
0
 /**
  *
  * This function to change numeric value to it binary string
  * and to get the file size
  *
  * @access private
  * @false  integer
  * @param  $fileSize
  * @return unknown
  *--------------------------------------------------------
  */
 private function fileSize($fileSize)
 {
     if (isNumeric($fileSize)) {
         $decr = 1024;
         $step = 0;
         while ($fileSize / $decr > 0.9) {
             $fileSize = $fileSize / $decr;
             $step++;
         }
         return round($fileSize, 2) . ' ' . strtoupper($this->_prefix[$step]);
     } else {
         return 'NaN';
     }
 }
Beispiel #6
0
<html>
<head>
<title>Console</title>
</head>
<body>

<?php 
function isNumeric($valor)
{
    return ereg('^[0-9]+$', $valor);
}
echo isNumeric("2016222a22");
?>

</body>
</html>
<?php

$var = true;
isNumeric($var);
$var = 'Hello!';
isNumeric($var);
$var = 3.14;
isNumeric($var);
$var = 8;
isNumeric($var);
function isNumeric($var)
{
    if (is_numeric($var)) {
        var_dump($var);
    } else {
        echo gettype($var) . "</br>";
    }
}
function getCustomFieldJoinerWhere($name, $value, $index, $comp, $numeric, $params)
{
    $res = "";
    $table = 'm' . $index;
    $field = "{$table}.meta_value" . (isNumeric($params, $numeric, false) ? '*1' : '');
    $res = " AND " . getComp($comp, $field, $value);
    if ($name != 'all') {
        $res = " AND ({$table}.meta_key='{$name}' " . $res . ") ";
    }
    return $res;
}
    $transp = isset($_POST['transportetipo']) ? $_POST['transportetipo'] : NULL;
    $nrtransp = isset($_POST['nrtransp']) ? $_POST['nrtransp'] : NULL;
    $escolaridade = isset($_POST['escolaridadetipo']) ? $_POST['escolaridadetipo'] : NULL;
} else {
    $action = $_GET['action'];
    $id = $_GET['id'];
    $disponibilidade_id = isset($_GET['disponibilidade_id']) ? $_GET['disponibilidade_id'] : NULL;
}
if ($action == "index") {
    #validar os paramentros informados
    if ($ano != NULL && isNumeric($ano)) {
        $router->addParam("ano", $ano);
    } else {
        $router->addMsgErro("Ano informado invalido.");
    }
    if ($mes != NULL && isNumeric($mes)) {
        $router->addParam("mes", $mes);
    } else {
        $router->addMsgErro("Mes informado invalido.");
    }
    $router->redirect();
    return;
} elseif ($action == "agendar") {
    if (!validateRecaptch()) {
        $router->addMsgErro("Codigo nao confere com a imagem!");
        $router->redirect();
        return;
    }
    #quantidade de visitante tem que ser maior que 10.
    if (isset($quantidade) && $quantidade <= 10) {
        $router->addMsgErro("Quantidade de pessoas tem que ser maior que 10!");
Beispiel #10
0
function fIsNumeric()
{
    return function ($d) {
        return isNumeric($d);
    };
}