2

this php row

if ($this->config->get('refprogram_sharing_enable') && !empty($this->config->get('refprogram_sharing_links'))) {

returns error message Fatal error: Can't use method return value in write context

2
  • this code seems to be alright, problem will be in other part of code Oct 1, 2016 at 13:56
  • Please paste the code around this line. This line seems to be fine, so the issue must be on the line before or after.
    – Scalpweb
    Oct 1, 2016 at 14:05

2 Answers 2

0

If you are using a version of PHP older than 5.5, you can only use variables within empty, and not method calls, otherwise it will throw the error you have received.

A solution would be to calculate the return value first, for example:

$links = $this->config->get('refprogram_sharing_links');

if ($this->config->get('refprogram_sharing_enable') && !empty($links)) {

Depending on the output of your get method, you could also try

&& $this->config->get('refprogram_sharing_links') !== false

Hard to tell if this would work without seeing the rest of your code, though.

0

In case if the first variable is string and the second is array:

$refprogram_sharing_enable = $this->config->get('refprogram_sharing_enable');
$refprogram_sharing_links = $this->config->get('refprogram_sharing_links');

if ( $refprogram_sharing_enable!='' && !empty($refprogram_sharing_links)) {

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.