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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC