You are here: Re: functions returning false « All PHP « IT news, forums, messages
Re: functions returning false

Posted by gerg on 05/04/06 22:51

robert wrote:
> | function echoarray($var){
> |
> | foreach( $var as $name ){
> |
> | echo "$name<br><br>";
> |
> | }
> |
> | }
> |
> | if ($db){ echo "Problem"; }
> |
> | the result is:
> |
> | Peter
> |
> | Paul
> |
> | Mary
>
> | So I can't figure out how exactly, when the function does execute, I'm
> | still getting the error message. Any ideas?
>
> moments like this make me chuckle. ;^)
>
> echoarray() doesn't return anything! and, no matter what, it always echos
> data to the browser/output buffer. if you put "return true;" as the last
> executed line within the body of that function, then it would behave more
> like you're expecting.
>
> try this:
>
> function echoArray($array)
> {
> if (!is_array($array)){ return false; }
> echo implode("<br><br>\n", $array);
> return true;
> }
>
> hth,
>
> me
>
>

Robert, your the man. I had misunderstood how functions return a value.
Thanks for your input, works great now!

Thanks again.

Greg

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация