Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3486086
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:59:11+00:00 2026-05-18T10:59:11+00:00

I would think the following piece of code should work, but it doesn’t (Edited:

  • 0

I would think the following piece of code should work, but it doesn’t (Edited: Now works in PHP 5.5+):

if (!empty($r->getError()))

Where getError() is simply:

public function getError()
{
    return $this->error;
}

Yet I end up with this error:

can’t use method return value in write context

What does this mean? Isn’t this just a read?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:59:11+00:00Added an answer on May 18, 2026 at 10:59 am

    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())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to do the following but I don't think this will work:
I have the following situation I think would be best to show in sample
you would think this would be obvious, but searching through documentation, SAP forums, Googling,
Would you guys think that a master page should be part of the company's
You'd think it would be easy, but keep reading. I can change many of
I have another newbie Python question. I have the following piece of code that
In the MVVM (Model-View-ViewModel) pattern should the ViewModel reference the view. I would think
I have a nice piece of functional and tested Ruby code that I would
I have the following piece of code: <html> <head> <script src=myplugin.js /> <script> $(document).ready(function()
The following piece of code tries to overwrite to different locations in a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.