php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54993 Return value fails to be used in empty
Submitted: 2011-06-04 14:53 UTC Modified: 2011-06-04 15:26 UTC
From: welfordmartin at gmail dot com Assigned:
Status: Not a bug Package: Compile Warning
PHP Version: 5.3.6 OS: Windows 7
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: welfordmartin at gmail dot com
New email:
PHP Version: OS:

 

 [2011-06-04 14:53 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-04 15:26 UTC] dtajchreber@php.net
-Status: Open +Status: Bogus
 [2011-06-04 15:26 UTC] dtajchreber@php.net
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
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Nov 29 08:01:23 2020 UTC