[UPHPU] pass variables into a function
Kevin Carter
email.bdr at gmail.com
Sun Jan 11 01:51:42 MST 2009
Provided you don't use extract() and only reference the indexes that you
need, any extra passed things shouldn't be a problem.
-Kevin-
Lamont Peterson wrote:
> On Saturday 10 January 2009 09:25:35 pm Kevin Carter wrote:
>> function do_something_awesome($params = array()) {
>> $default = array(
>> 'a' => 'a',
>> 'b' => 'b',
>> );
>> $params = array_merge($default, $params);
>>
>> ....
>>
>> }
>
> Nice ... but not equivalent to what I had suggested.
>
> The (minor) security problem with this one is that any parameters can be
> passed; we've lost control of what can be injected into the function. Other
> than that, I like that array_merge () approach, it would certainly run faster
> this way. Thank you.
>
> [snip]
>
>
> ------------------------------------------------------------------------
>
>
> _______________________________________________
>
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
More information about the UPHPU
mailing list