Actually, although suppressing the E_NOTICE, this is not exactly the
behavior you want.

What if $_GET['Does']['Not']['Exist'] really doesn't exists? It is then
created and assigned to $param when passed as an argument to the param
function. Therefore polluting $_GET with another unused array and array
element, creating more internal hashes for no reason. Try that with 50 form
vars and you be creating 50 more variables that really never even existed.
Maybe not much of a foot print but very unnecessary.

There are probably many different ways you can implement this functionality
at a user-level, try the php.general list.


"Ferdinand Beyer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 15 Apr 2004 at 11:47, Jason Garber wrote:
>
> > a. the actual variable in question could not be passed
>
> This is wrong, too. Look at this example:
>
> <?php
> error_reporting(E_ALL | E_STRICT);
>
> function param(&$param, $default, $type = null)
> {
>     if (!isset($param)) {
>         $param = $default;
>     }
>     if (is_string($type)) {
>         settype($param, $type);
>     }
> }
>
> $_GET['Exists'] = 0;
>
> param($_GET['Exists'], 1, 'string');
> param($_GET['Does']['Not']['Exist'], 1, 'double');
>
> var_dump($_GET);
> ?>
>
> Output:
> ----------------------------------------
> array(2) {
>   ["Exists"]=>
>   string(1) "0"
>   ["Does"]=>
>   array(1) {
>     ["Not"]=>
>     array(1) {
>       ["Exist"]=>
>       float(1)
>     }
>   }
> }
>
> Exactly the behavior you are looking for. Not even an E_NOTICE.
>
> --
> Ferdinand Beyer
> <[EMAIL PROTECTED]>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to