php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64081 Trim can return false
Submitted: 2013-01-26 09:59 UTC Modified: 2013-01-26 10:38 UTC
From: blueAlien86 at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: blueAlien86 at gmail dot com
New email:
PHP Version: OS:

 

 [2013-01-26 09:59 UTC] blueAlien86 at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.trim#refsect1-function.trim-
returnvalues
---

Taken from Empty function documentation:
will not work: empty(trim($name)). Instead, use trim($name) == false.

Test script:
---------------
unset($name);
echo empty(trim($name)); //FAILS
echo trim($name); //FALSE


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-26 10:27 UTC] krakjoe@php.net
Can you please clarify the bug you are reporting ?
 [2013-01-26 10:30 UTC] blueAlien86 at gmail dot com
In the documentation for the trim function under return values, only a string is 
listed. I am requesting that FALSE also be added to the documentation as a return 
value.
According to the empty function, if an empty string is passed to trim, it will 
return FALSE.
 [2013-01-26 10:38 UTC] krakjoe@php.net
False is not returned in the example you gave.

<?php
$name = "test";

unset($name);

var_dump(trim($name));
?>
 [2013-01-26 10:38 UTC] krakjoe@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Apr 15 11:01:24 2021 UTC