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
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: 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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC