|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
1 + 37 = ?
Subscribe to this entry?

 [2012-06-12 22:08 UTC] zkizzik at gmail dot com
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 :-/


Add a Patch

Pull Requests

Add a Pull Request


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-2022 The PHP Group
All rights reserved.
Last updated: Wed May 18 13:05:45 2022 UTC