#49665 [NEW]: bad example for filter_var() in documentation
| From: | alex dot schuch at gmx dot de | Date: | Fri, 25 Sep 2009 08:33:19 +0000 |
| Subject: | #49665 [NEW]: bad example for filter_var() in documentation | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-2817@lists.php.net to get a copy of this message | ||
From: alex dot schuch at gmx dot de
Operating system: -
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: bad example for filter_var() in documentation
Description:
------------
The example given at
"http://www.php.net/manual/en/filter.examples.validation.php"
makes people
believe the sanitation always work that way, which is not the case.
The example should be like this:
if (($int_c = filter_var($int_c, FILTER_VALIDATE_INT, $options)) !==
FALSE) {
echo "This (int_c) integer is considered valid (between 0 and 3) and
is $int_c.";
}
This is related to <http://bugs.php.net/bug.php?id=42136>.
Reproduce code:
---------------
<?php
$int_c = '4';
$options = array(
'options' => array(
'min_range' => 0,
'max_range' => 3,
)
);
// [...]
$options['options']['default'] = 0; // has "1" in documentation
if ($int_c = filter_var($int_c, FILTER_VALIDATE_INT, $options)) {
echo "This (int_c) integer is considered valid (between 0 and 3) and
is $int_c.";
}
?>
Expected result:
----------------
This (int_c) integer is considered valid (between 0 and 3) and is 0.
Actual result:
--------------
-no output-
--
Edit bug report at http://bugs.php.net/?id=49665&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49665&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49665&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49665&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=49665&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49665&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=49665&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=49665&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=49665&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=49665&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=49665&r=support
Expected behavior: http://bugs.php.net/fix.php?id=49665&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=49665&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=49665&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=49665&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49665&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49665&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=49665&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=49665&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=49665&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=49665&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=49665&r=mysqlcfg