Jump to content

Can't use function return value in write context


bazianm

Recommended Posts

Hi,

 

I am kind of new to php (although an experienced programmer in other languages). I am working on an application and I have a problem which I have been unable to figure out. I have googled it and still cannot get a handle on it. I have boiled it down to a simple example. Here's the code:

 

<?php

$array = gettest();

foreach ($array as $item)
{
if(gettype($item) == 'NULL') echo '<H1>WOW! A NULL!</H1>';
echo gettype($item).'<br>';
}


function gettest(){
$lcFilter = "1|2|3";
$laFilter = explode('|',$lcFilter);

if(!empty(laFilter(0))) laReturn('jobid') = laFilter(0);
if(!empty(laFilter(1))) laReturn('stateid') = laFilter(1);
if(!empty(laFilter(2))) laReturn('storeid') = laFilter(2);

return $laReturn;
}
?>

 

When I run this, the line:

 

	if(!empty(laFilter(0))) laReturn('jobid') = laFilter(0);

 

generates the error:

 

Fatal error: Can't use function return value in write context in C:\xampp\htdocs\test.php on line 16

 

I cannot think of what is wrong with the code. It seems simple enough. Any assistance would be greatly appreciated.

 

Thanks

Link to comment
Share on other sites

I figured it out. In this case, the array needed to use square brackets. It's funny, I had another case where I had to change it to regular parens... Not sure why but it seems to work now in my little test program.

 

Thanks anyway!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.