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
 [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: Fri Apr 16 03:01:23 2021 UTC