php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47381 Some expressions (of classes) don't behave logical
Submitted: 2009-02-13 13:34 UTC Modified: 2009-02-16 09:58 UTC
From: t dot nickl at exse dot de Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 6CVS-2009-02-13 (snap) OS: Ubuntu 8.10
Private report: No CVE-ID: None
 [2009-02-13 13:34 UTC] t dot nickl at exse dot de
Description:
------------
class A
{
        public function getName()
        {
                return("a");
        }
}

//Issue 1:
//This produces "syntax error, unexpected T_OBJECT_OPERATOR":
echo new A()->getName();

//This works:
$_= new A();
echo $_->getName();


//Issue 2:
//This produces "Can't use function return value in write context":
$b= " a";
var_dump(empty(trim($a)));

//This works:
$b= " a";
$_= trim($a);
var_dump(empty($_));



//In php, I must assign an expression to a variable first 
// before being able to use it at some points? Why?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-13 21:11 UTC] felipe@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


 [2009-02-16 09:58 UTC] t dot nickl at exse dot de
Thank you!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 17 14:00:02 2025 UTC