News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Davey Shafik's Blog:
Return Values
February 04, 2009 @ 11:14:28

Davey Shafik has taken a look at return values and keeping them standard when handing them back from the results of a database query.

In #phpc we recently had a discussion about function return values; specifically from database queries. I'm going to go on a (admittedly, rather sturdy looking) limb and say this applies to pretty much any function that returns from a data resource, not just a database .

His personal preference is to return the results data if there's matching information but to return a false value if there is an error/not results were found. He includes a snippet of example code to show the structure he's talking about. Some of the comments on the post mention things like exception handling, other similar methods other developers use and the use of nulls.

0 comments voice your opinion now!
return value array false null exception comment


blog comments powered by Disqus

Similar Posts

David Coallier's Blog: PEAR is using jQuery et new features

Federico Cargnelutti: TDD: Checking the return value of a Stub

DevShed: Checking Boolean Values with Filters in PHP 5

Wez Furlong's Blog: HTTP POST from PHP, without cURL

SitePoint PHP Blog: Pimpin Harry’s pretty bluescreen


Community Events

Don't see your event here?
Let us know!


voicesoftheelephpant threedevsandamaybe series extension unittest framework language laravel5 podcast introduction version laravel security interview library opinion symfony api community release

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework