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 Commented 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. Commented 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.

Sign up to request clarification or add additional context in comments.

Comments

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)) {

}

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.