bazianm Posted June 7, 2012 Share Posted June 7, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/263828-cant-use-function-return-value-in-write-context/ Share on other sites More sharing options...
bazianm Posted June 7, 2012 Author Share Posted June 7, 2012 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! Quote Link to comment https://forums.phpfreaks.com/topic/263828-cant-use-function-return-value-in-write-context/#findComment-1351962 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.