php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44585 htmlentities returns empty string when operation on a null value
Submitted: 2008-04-01 03:14 UTC Modified: 2016-12-31 00:19 UTC
Votes:28
Avg. Score:3.1 ± 0.4
Reproduced:2 of 4 (50.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: eran at octabox dot com Assigned:
Status: Open Package: Strings related
PHP Version: 5.2.5 OS: Windows XP Professional SP2
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
49 - 9 = ?
Subscribe to this entry?

 
 [2008-04-01 03:14 UTC] eran at octabox dot com
Description:
------------
The htmlentities function returns an empty string when used on a null value. This might seem irrelevant, however the htmlentities is used regularly to escape data before using it in a database query. A null value might be needed in such queries, and it would be preferred if it does not need to be considered a special case if a part of an data escaping routine.

For example, the Zend_Filter_Input component of the Zend_Framework uses htmlentities as the default escape filter. Passing null values in an escape routing would result in null values erroneously being converted to empty strings. 

Reproduce code:
---------------
var_dump(htmlentities(null));

Expected result:
----------------
NULL

Actual result:
--------------
string(0) ""

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-31 00:19 UTC] cmb@php.net
-Package: Feature/Change Request +Package: Strings related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 14 08:01:30 2019 UTC