Bug #54993 [Opn->Bgs]: Return value fails to be used in empty
| From: | dtajchreber@php.net | Date: | Sat, 04 Jun 2011 13:26:05 +0000 |
| Subject: | Bug #54993 [Opn->Bgs]: Return value fails to be used in empty | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161185@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54993&edit=1
ID: 54993
Updated by: dtajchreber@php.net
Reported by: welfordmartin at gmail dot com
Summary: Return value fails to be used in empty
-Status: Open
+Status: Bogus
Type: Bug
Package: Compile Warning
Operating System: Windows 7
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
"Note:
empty() only checks variables as anything else will result in a parse error. In
other words, the
following will not work: empty(trim($name))."
$c = cleanData::GET("test");
if(empty($c)) {
/* etc */
} else {
/* etc */
}
[1] http://php.net/empty
Previous Comments:
------------------------------------------------------------------------
[2011-06-04 14:53:52] welfordmartin at gmail dot com
Description:
------------
I have built an MVC (lightweight MVC) now in this is static class ("cleanData")
with method for (POST, GET, URL) and use addSlashes on them,
the problem is when i use the return data in the empty function
("Fatal error: Can't use function return value in write context")
Test script:
---------------
class cleanData{
public static function GET($key){
return addslashes($_GET[$key]);
}
}
if(empty(cleanData::GET("test"))){
echo "empty";
}else{
echo cleanData::GET("test");
}
Expected result:
----------------
if loaded with ?test=1 i should see
1 on output,
if loaded with ?test=, or without test in url i should see
empty
Actual result:
--------------
Fatal error: Can't use function return value in write context
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54993&edit=1