-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 i'm not worried about speed of execution or actual number of statements. (although i am looking to shave some typing and make my code a little clearer) i think that using: $r = function() or return 0; is more readable and easier on the wrists than the other two ways and i'm looking for an equally terse way of accomplishing the same thing with PHP.... > -----Original Message----- > From: Sterling Hughes [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 26, 2001 4:57 PM > To: scott [gts] > Cc: php > Subject: Re: [PHP] How would you code: $r = func() or return 0? > > > On Wed, 26 Sep 2001, scott [gts] wrote: > > > > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > I thought i'd ask for your comments on how you'd code this > > common perl code with PHP: > > > > $value = some_function() or return 0; > > > > i usually code my functions to return 0 or "" on error, but > > have to use the following code to handle it... neither seem > > like a good solution to me. > > > > this way decreses the readability of the code: > > if (!$value = some_function) > > return 0; > > > > and this way adds an unnecessary if() statement: > > $value = some_function() > > if (!$value) { > > return 0; > > } > > The last way is how you would do it... And FYI, its an extra if > statement in the Perl code too (speed wise)... > > -Sterling > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com> iQA/AwUBO7JLW8aXTGgZdrSUEQKjQACg4GdkrVjTodv/wV3IUCTAKHidCIYAoKUs xzlYjq4KIbblwukkixk1gfCC =jUzq -----END PGP SIGNATURE----- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]