php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39708 Confusing error message for empty(func())
Submitted: 2006-12-01 18:37 UTC Modified: 2006-12-20 14:54 UTC
Votes:21
Avg. Score:4.2 ± 0.8
Reproduced:20 of 20 (100.0%)
Same Version:4 (20.0%)
Same OS:14 (70.0%)
From: zizka at seznam dot cz Assigned:
Status: Wont fix Package: Unknown/Other Function
PHP Version: 6.0.0 OS: All
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-12-01 18:37 UTC] zizka at seznam dot cz
Description:
------------
When calling empty() with a return value from function, it says:

Can't use method return value in write context

It would be definitely less confusing if it said something like:

empty() accepts only variables as a parameter.

Reproduce code:
---------------
<?php
empty(trim(""));
?>

Expected result:
----------------
Fatal error: empty() accepts only variables as a parameter in  ... on line 2

Actual result:
--------------
Fatal error: Can't use method return value in write context in ... on line 2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-01 18:51 UTC] tony2001@php.net
The error message is clear enough and is used in all cases when you're trying to change function's return value, like this:
<?php function foo () { return 1; } foo() = 1; ?>
 [2006-12-20 14:54 UTC] zizka at seznam dot cz
But this is not the case: I am not trying to change function's return value; empty() is not supposed to write anything, it just examines the variables. So here is the confusion.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC