NYCPHP Meetup

NYPHP.org

[nycphp-talk] Accessing non-existent array elements ok?

Daniel Convissor danielc at analysisandsolutions.com
Mon Aug 18 23:27:34 EDT 2008


On Mon, Aug 18, 2008 at 01:09:18PM -0400, Kenneth Downs wrote:
> David Mintz wrote:
> >On Mon, Aug 18, 2008 at 8:51 AM, Kenneth Downs <ken at secdat.com 
> ><mailto:ken at secdat.com>> wrote:
> >
> >    function a(&$array, $key,$default='') {
> >
> >Does using an array reference &$array buy you anything in this instance?
> 
> The basic idea is you don't know how big the array is and you don't want 
> to pass anything more than you want to.

PHP functions always act on a pointer/reference of the input value UNTIL 
you write to it.  So, in this case, making $array a reference buys you 
nothing.  I don't know if it penalizes you, though.

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list