On Wed, Apr 20, 2011 at 6:00 PM, Jonathan Bond-Caron <jbo...@openmv.com>wrote:

> On Wed Apr 20 10:55 AM, Mark wrote:
> >
> > function varset($arr, $key, $default = '') { return (isset($arr[$key])
> > ? $arr[$key] : $default); }
> >
> > where the call would be:
> > $var = varset($_GET, 'var');
> >
> > I personally like both ways...
> > My proposal is to make this function a core php function in PHP 5.4.
> > The added benifit is obvious. People can, with this, use a way shorter
> > notation to validate if a given array element exists. Right now that
> > needs to be done with a ternary, filter_var or some other method
> > (there are quite a few ways to check for existence).
> >
> > I tried to look in the PHP source to see if i could make a patch to
> > add this but i couldn't find the function that defines the isset
> > function (i wanted to base it on that). So a pointer to the right
> > location would be nice (along with docs that tell me what i all need
> > to do to implement a new php function).
>
>
> https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_language_parser.y?rev
> ision=306938&view=markup
>
> Look for "isset_variables:", then zend_do_isset_or_isempty
>
> isset() lives in the parser and requires some advanced knowledge of the
> opcodes (personally I'm not there yet)
>

Oh boy, i never ever did anything in the core PHP coding so i'm certainly
not likely to be able to understand all of that. (yet)

>
> >
> > So, what do you think of this?
> >
>
> I like the idea, it could also be called vardef() or var_default()
>
>
>
@ the rest.
The list idea is nice, but i don't really see the added value for it.. Lets
keep it simple, oke :)
As for that other thread: "[PHP-DEV] Implicit isset/isempty check on
short-ternary operator"
I don't really know much of it, but does that mean that my suggestion is
rejected even before i made an RFC for it?

Regards,
Mark

Reply via email to