-3

I am working on a PHP project and doing the development on Windows and everything works perfectly fine.

When I install the code onto a Linux box the page breaks and I get the following error:

 PHP Fatal error:  Can't use function return value in write context

The line that this error is referring to is

if (!isset(parent::getPostArray()["searchRefOnly"]))

And all the parent::getPostarray() function does is return an array as follows:

protected function getPostArray()
        {
            return $this->postArray;
        }

The above code works perfectly fine on Windows, so why not on Linux?

halfer
  • 19,824
  • 17
  • 99
  • 186
Boardy
  • 35,417
  • 104
  • 256
  • 447
  • 1
    perhaps different php version? also it's duplicate – Marcin Orlowski Jan 22 '16 at 11:08
  • Duplication, solution is to upgrade to a higher PHP version. Works in PHP 5.5 and above. – Zhafur Jan 22 '16 at 11:09
  • 1
    How is that a duplicate, that is referring to the empty function so they are trying to make a change. I'm not writing any changes I'm just checking if a value in a returned array exists – Boardy Jan 22 '16 at 11:10

1 Answers1

0

you can use this way

$result = $this->getPostArray();//parent::getPostArray()
if (!empty($result)){}
Gagan Upadhyay
  • 255
  • 2
  • 11