Re: Implicit isset/isempty check on short-ternary operator
| From: | Richard Quadling | Date: | Thu, 14 Apr 2011 10:18:41 +0000 |
| Subject: | Re: Implicit isset/isempty check on short-ternary operator | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51887@lists.php.net to get a copy of this message | ||
On 14 April 2011 11:07, Reindl Harald <h.reindl@thelounge.net> wrote:
>
> Am 14.04.2011 12:02, schrieb Richard Quadling:
>
>> I always declare my variables. So, I don't want to use isset() as they
>> will be an incorrect test. I use is_null(). Specifically testing the
>> value. If I've made a mistake and NOT declared the variable (or made a
>> typo), I want to know. I don't want to hide it with isset()/empty()
>
> yes and no
>
> $config['modulename'] = array
> (
> 'icon' => 'bla.gif',
> 'default_params' => array
> (
> 'autocleanup' => 1,
> 'ignore_user_abort' => 0,
> )
> );
>
>
> if 'default_params' are optional you NEED isset() to decide
> do something with them or skip operations
>
>
I think that depends upon the developer.
I don't mix the tests for existence.
Mixing the tests means a typo in the isset() will hide the lack of existence.
But array_key_exists() is not going to do that. If the key exists then
I can process it. If not, then I can't.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY