Re: Re: Construct Request
| From: | Marcus Boerger | Date: | Thu, 15 Apr 2004 21:27:57 +0000 |
| Subject: | Re: Re: Construct Request | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9234@lists.php.net to get a copy of this message | ||
Hello Justin,
Thursday, April 15, 2004, 5:28:29 PM, you wrote:
>> echo setor($required_variable, die('error...');
>> or
>> echo setor($error, '');
>> or
>> echo setor($sMessage, $sDefaultMessage).
>> or
>> $z = setor($_GET['z'], 'Default');
>> $z = setor($_GET['z'], 'Default');
> Whats wrong with defining a user-level function?
> function setor_array(&$array, $key, $default = 0)
> {
> return isset($array[$key']) ? $array[$key] : $default;
> }
> $nCustID = (int) setor_array($_GET, 'nCustID', 0);
Such a user function would be todays best practice since
neither a userfunction setor($val, $else) nor an internal implementation
of such a function would work. Here Derick's argument comes into place that
we cannot simply change the way variables and array offsets are accessed.
The above setor_array() doesn't have that problem though.
--
Best regards,
Marcus mailto:helly@php.net