Re: php programming style

From: Date: Thu, 21 Nov 2002 18:07:46 +0000
Subject: Re: php programming style
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-125449@lists.php.net to get a copy of this message
It depends on many issues...do you have a set standard that you use when programming. 1. does it make sense to do it that way. 2. are there performance issue 3. is it understandable for maintenance by yourself or others. 4. does the function require a return value, if so which type. I think that some of the above question might help you out. However, from a programming standpoint i like to make sure that my functions return the same type at least. Some feel different about this and return various type (ie, int, strings, arrays)... HTH On Thu, 2002-11-21 at 10:57, Beau Hartshorne wrote: > Hi, > > I'm curious if it's bad coding style for a function to return a value on > success, or simply "false" on fail. Here's what I mean: > > <?php > > function foo($number) > { > if (is_numeric($number)) { > return $number . ' is a number.'; > } else { > return false; > } > } > > if ($string = foo(1)) { > echo $string; > } else { > echo 'error'; > } > > ?> > > Is this ok? > > Thank you, > > Beau -- Ray Hunter email: bigdog@venticon.com www: http://venticon.com

« previous php.general (#125449) next »