Be careful comparing ReflectionParameter::getType() and gettype() as they will not return the same results for a given type.
string - string // OK
int - integer // Type mismatch
bool - boolean // Type mismatch
array - array // OK(PHP 4, PHP 5, PHP 7, PHP 8)
gettype — Resituisce il tipo di una variabile
Resituisce il tipo della variabile PHP var. Per
controllare il tipo, utilizzare le funzioni is_*.
varLa variabile di cui controllare il tipo.
I valori possibili per la stringa restituita sono:
Example #1 Esempio di gettype()
<?php
$data = array(1, 1., NULL, new stdClass, 'foo');
foreach ($data as $value) {
echo gettype($value), "\n";
}
?>Il precedente esempio visualizzerà qualcosa simile a:
integer double NULL object string
Be careful comparing ReflectionParameter::getType() and gettype() as they will not return the same results for a given type.
string - string // OK
int - integer // Type mismatch
bool - boolean // Type mismatch
array - array // OK