<?php
function check_type($value)
{
var_dump($value);
return $value;
}
$values = [
null,
false,
true,
42,
45.15,
'hello',
['array1', 'array2', 15, 25],
new stdClass(),
gmp_init('4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444'),
];
foreach ($values as $value) {
$filtered_var = filter_var($value, FILTER_CALLBACK, ['options' => 'check_type']);
var_dump($filtered_var);
}
- Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
- string(0) ""
string(0) ""
string(0) ""
string(0) ""
string(1) "1"
string(1) "1"
string(2) "42"
string(2) "42"
string(5) "45.15"
string(5) "45.15"
string(5) "hello"
string(5) "hello"
string(6) "array1"
string(6) "array2"
string(2) "15"
string(2) "25"
array(4) {
[0]=>
string(6) "array1"
[1]=>
string(6) "array2"
[2]=>
string(2) "15"
[3]=>
string(2) "25"
}
bool(false)
bool(false)
preferences:
50.53 ms | 407 KiB | 5 Q