Can't use method return value in write context
empty()
needs to access the value by reference (in order to check whether that reference points to something that exists), and PHP before 5.5 didn't support references to temporary values returned from functions.
However, the real problem you have is that you use empty()
at all, mistakenly believing that "empty" value is any different from "false".
Empty is just an alias for !isset($thing) || !$thing
. When the thing you're checking always exists (in PHP results of function calls always exist), the empty()
function is nothing but a negation operator.
PHP doesn't have concept of emptyness. Values that evaluate to false are empty, values that evaluate to true are non-empty. It's the same thing. This code:
$x = something();
if (empty($x)) …
and this:
$x = something();
if (!$x) …
has always the same result, in all cases, for all datatypes (because $x
is defined empty()
is redundant).
Return value from the method always exists (even if you don't have return
statement, return value exists and contains null
). Therefore:
if (!empty($r->getError()))
is logically equivalent to:
if ($r->getError())
PHP Fatal Error can't use function return value in write context
you can use this way
$result = $this->getPostArray();//parent::getPostArray()
if (!empty($result)){}
Can't use function return value in write context in yii2
Issue:-
if(count($sql1)=0) //is an assignment not a comparison
Change it to:-
if(count($sql1)==0)
Can't use function return value in write context when using mysqli_num_rows()
Write this
if(mysqli_num_rows($test) == 0)
Instead of,
if(mysqli_num_rows($test) = 0)
can't use function return value in write context - error in line 7
empty()
is a PHP language construct and only supports variables and expressions, and no function calls as arguments.
You will have to assign the result of your call to a variable first and then do the empty check like so:
$reviewPrice = get_post_meta($review->ID,'review_price',true);
if(!empty($reviewPrice)){
Related Topics
How to Store My Users' Passwords Safely
Allow PHP Sessions to Carry Over to Subdomains
How to Get Parameters from a Url String
How to List Has Same Id Data With While Loop in PHP
How to Create Custom Helper Functions in Laravel
How to Send a Firebase Cloud Messaging Notification Without Use the Firebase Console
Failed to Connect to Mailserver At "Localhost" Port 25
Displaying HTML With Blade Shows the HTML Code
How to Implement Authorization Using a Telegram API
In_Array() and Multidimensional Array
Accessing @Attribute from Simplexml
How to Convert Json String to Array
Download File to Server from Url
How to Implement a Good Profanity Filter
How to Generate in PHP All Combinations of Items in Multiple Arrays