You are here: Re: Returning NULL vs. returning FALSE « PHP Programming Language « IT news, forums, messages
Re: Returning NULL vs. returning FALSE

Posted by Thomas Mlynarczyk on 11/18/05 23:43

Also sprach Erwin Moller:

> As Micha wote: Now you cannot distinguish between an 'error NULL' and
> 'real NULL'.

> And what about a function that could return NULL and false, both as
> usefull values?

In that case, I suppose, I would really have a problem. Still, it seems to
me that the case where a function could "legally" return NULL is much rarer
than that of a function returning a boolean. On the other hand, I just
realized, if a function would not normally return anything, then booleans
are "required" to indicate failure (FALSE) or success (TRUE). So that might
have been a reason, too, for choosing FALSE to indicate an error, I suppose.

But apart from such considerations - there is thus no technical drawback to
using NULL instead of FALSE to indicate an error?

> So if you find yourself in such a situation, be creative.
> eg: always return your value in an array (only one element big if
> needed), OR let it return false.

Indeed, a creative proposal. I will keep this in mind.

Thanks to both of you!

Greetings,
Thomas

 

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

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