php-general | 2001092
Date: 09/26/01
- Next message: Sterling Hughes: "Re: [PHP] How would you code: $r = func() or return 0?"
- Previous message: Chris Lee: "[PHP] Re: 2D array from file"
- Next in thread: Sterling Hughes: "Re: [PHP] How would you code: $r = func() or return 0?"
- Reply: Sterling Hughes: "Re: [PHP] How would you code: $r = func() or return 0?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
-----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;
}
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBO7I+l8aXTGgZdrSUEQLW3wCbBhH8w+P+EgJxvs46H9JUtx9q0iUAoKeg
pRwrJ6NH230r0EQZl3Wvc5Wl
=sUof
-----END PGP SIGNATURE-----
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Sterling Hughes: "Re: [PHP] How would you code: $r = func() or return 0?"
- Previous message: Chris Lee: "[PHP] Re: 2D array from file"
- Next in thread: Sterling Hughes: "Re: [PHP] How would you code: $r = func() or return 0?"
- Reply: Sterling Hughes: "Re: [PHP] How would you code: $r = func() or return 0?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

