|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-05-15 04:14 UTC] dev at pixandlog dot com
Description:
------------
Hello.
I have found input_get with boolean weird. With a bad argument in form, i got a boolean false. Before i reciept value null.
It is not a good choice because we don't create a error message or exception without a differential value.
Please check revision R1.36 of logical_filters.c ->
void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL)
LINE=237
} else {
zval_dtor(value);
ZVAL_BOOL(value, 0);
}
------------------------
logical_filters.c - R1.21
void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL)
LINE=218
} else {
zval_dtor(value);
Z_TYPE_P(value) = IS_NULL;
}
-------------------------
PHP5.1.4
Thanks you for your job.
Xavier.
Reproduce code:
---------------
<?php
//$_GET['test'] == 'foobar';
$source = INPUT_GET;
$name = 'test';
$ret = input_get($source, $name);
var_dump($ret);
if ($ret === null) {
echo 'Error message.';
}
else {
echo 'Good message.';
}
?>
Expected result:
----------------
NULL
Actual result:
--------------
false
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 06:00:01 2025 UTC |
Sorry i would wrote this : <?php //$_GET['test'] == 'foobar'; $source = INPUT_GET; $name = 'test'; $filter = FILTER_VALIDATE_BOOLEAN; $ret = input_get($source, $name, $filter); var_dump($ret); if ($ret === null) { echo 'Error message.'; } else { echo 'Good message.'; } ?>