[TYPO3-core] RFC: Avoid double checking of match-conditions
Martin Kutschker
Martin.Kutschker at blackbox.net
Fri Feb 17 11:28:31 CET 2006
René Fritz <rene at typo3.org> writes on
Fri, 17 Feb 2006 11:24:33 +0100 (MET):
>
>
> > >You can enhance this by passing the big arrays only as references:
>
> I thought this too, but it's not true. PHP only pass a "pointer" no
> matter if
> you pass by value or by reference. When you actually change the array
> a copy of the changed values will be made.
>
> I suggest not to use references when not needed. This can cause
> strange bugs and is harder to overview.
In which case? In the workOnArray-case or in the createArray-case?
I agree that returning a reference in the latter case is probably not really needed, but I really think that any function that works on an array should take it as a reference.
NO:
function workOnArray($a) {}
$a = workOnArray($a);
YES:
function workOnArray(&$a) {}
workOnArray($a);
Of course you should take care when designing such a function if you really want to work on the array.
Masi
More information about the TYPO3-team-core
mailing list