php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8287 Parse error around empty() when parameter is a object member function
Submitted: 2000-12-15 18:39 UTC Modified: 2000-12-15 18:54 UTC
From: dbellizzi at valinux dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: Linux 2.2.14 (debian 2.2)
Private report: No CVE-ID: None
 [2000-12-15 18:39 UTC] dbellizzi at valinux dot com
The following script generates a parse error on line 8 (Parse error: parse error, expecting `')'' in /home/dbellizzi/cvs/crm/htdocs/test.php on line 8

<?php
class Foo {
        function blah(){
                return "abcd";
        }
}
$foo = new Foo();
if (empty($foo->blah())){
        echo("foo->blah is empty");
}
?>

However, when changed to this script that assigns the variable before checking it with empty(), it works fine:
<?php
class Foo {
        function blah(){
                return "blah";
        }
}
$foo = new Foo();
$blah = $foo->blah();
if (empty($blah)){
        echo("foo->blah is empty");
}
?>

I have duplicated this on a few different machines, but if you need information on my setup, libraries, etc. please email me and I'd be happy to provide more information

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-15 18:54 UTC] hholzgra@php.net
please have a look at the manual page at 
        http://php.net/empty

"empty -- Determine whether a variable is set"

empty() does only accept variables as argument.
not general expressions
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Jul 05 16:00:01 2026 UTC