How would you code: $r = func() or return 0?

From: Date: Wed, 26 Sep 2001 18:55:24 +0000
Subject: How would you code: $r = func() or return 0?
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-2069@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Since there are various emails flying around this list asking for comments on coding style, comment style, etc. 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/AwUBO7Ikm8aXTGgZdrSUEQL/pgCdGQoZLHMH3JtE0qr0t0GGR5fDSVAAn1Nr A6IKTQ6ebnm/XZPpcOVxVOLm =05Xf -----END PGP SIGNATURE-----

« previous php.pear.dev (#2069) next »