david noronha david noronha - 1 month ago 7
PHP Question

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

I have this issue where I am posting a response into the controller, however it throws this error. This is the first time I am coming across this error.

Kindly find the code below:

if (isset($this->input->post('responseCode')))
{
echo '<p><strong>Cardstream Response</strong></p>';
echo '<pre>';
print_r($this->input->post());
echo '</pre>';
}


It is pointing at this particular line
if (isset($this->input->post('responseCode')))


This is a cardstream integration. Unfortunately I haven't found the library for cardstream in codeigniter, hence I am using the Core PHP code for the same.

Any help will be greatly appreciated. Thanks.

Answer

You are using isset() on a method, which presumably returns a expression result. You cannot do that because isset() is only used on variables. Try checking if it's null instead:

if ($this->input->post('responseCode') !== null) {...

Or simply:

if ($this->input->post('responseCode')) {...
Comments