03-24-2010, 05:31 PM
i understand &$model means passing by reference? like in java or C++
but i dont understand what & for &translateModel
anyone knows what this is?
03-24-2010, 05:38 PM
Returned by reference. This is an interesting one, essentially you bind a variable to the results of a function. As it changes, the results originally placed change as well. The only time I've needed to use this was when I used a counter & time elapse within post-parsed templating (since the templates were not developed until the last step). This was necessary otherwise the resulting time and counts were limited to the time the function had been called instead of the time and counts upon completion (including the queries for the template data itself).
That make sense? This is a harder one to explain, but it would be quite reflective of returning a void * from you're function in C.
Here is some information about its usage: http://php.ca/manual/en/language.references.return.php
03-24-2010, 05:52 PM
hmmm thanks i have never used this trick in php.... thanks
03-24-2010, 06:05 PM
Yep, np. Not really a trick though; it has very limited usefullness (like variable variables hah). So far, I've used this approach only once, and haven't really found a situation it was necessary in again (and as specified, unlike C with returning a pointer, PHP will have no benefit in performance by this usage since it uses a copy-on-write approach to its variables anyway).