php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62304 string cast dont work with zero values
Submitted: 2012-06-12 22:08 UTC Modified: 2012-06-12 22:17 UTC
From: zkizzik at gmail dot com Assigned:
Status: Closed Package: Filter related
PHP Version: 5.4.3 OS: All
Private report: No CVE-ID: None
 [2012-06-12 22:08 UTC] zkizzik at gmail dot com
Description:
------------
string cast dont work with zero values.

Test script:
---------------
// test.php?price=0
$price = $_GET['price'];
echo htmlspecialchars((string)$price, ENT_QUOTES); // empty
// cast (string) for prevent errors with arrays, for example test.php?price[][][][]=disclosureHere

Expected result:
----------------
0 not empty

Patch in php:
// test.php?price=0
$price = $_GET['price'];
echo (($price === '0') ? '0' : htmlspecialchars((string)$price, ENT_QUOTES));

Actual result:
--------------
empty value :-/

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-12 22:17 UTC] zkizzik at gmail dot com
-Status: Open +Status: Closed
 [2012-06-12 22:17 UTC] zkizzik at gmail dot com
Invalid. x__x
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC