Re: New construct discussion Summary
| From: | Marc Richards | Date: | Sun, 11 Jul 2004 18:54:30 +0000 |
| Subject: | Re: New construct discussion Summary | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-11096@lists.php.net to get a copy of this message | ||
Marc Richards wrote:
I don't think a function named param() really fits, but I do like the idea of adding a type check (or in the case of PHP a type cast) to the function. $level = (int) (isset($_SESSION['level']) ? $_SESSION['level'] : (isset($_REQUEST['level']) ? $_REQUEST['level'] : 1)) becomes $level = value($_SESSION['level'], $_REQUEST['level'], 1, INT);P.S. Aside from simply moving the type cast into the function, this would also avoid doing the cast on the default variable, which could be particularly useful if you want $level to be NULL...in which case it might be better to switch the order of the last two params since INT is "bound to" the variables, not the default $level = value($_SESSION['level'], $_REQUEST['level'], INT, 1); or $level = value($_SESSION['level'], $_REQUEST['level'], INT, NULL); or $level = value($_SESSION['level'], $_REQUEST['level'], INT); Marc