On Fri, July 22, 2005 11:46 am, Surendra Singhi said: > > "Richard Lynch" <ceo@xxxxxxxxx> writes: >> The & operator is not, as far as I know, defined for an array assignment >> operation. >> >> True, you can use & in the parameter list in some versions to keep PHP >> from copying the whole array. But that does not legitimatize what you >> are >> doing, I don't think. > > I never claimed, what I was doing was correct, rather I didn't knew well > enough that 'PHP is not C++', and I was misunderstanding how reference and > global variables work in PHP. >> >> I could be 100% wrong. I've never even *TRIED* to use a reference to an >> array because I simply don't want to write code that confusing in the >> first place. > > I don't think it will make the code confusing, but the person looking at > the > code should understand how reference and global variables work. Using > reference variables avoids unnecessary extra copying of objects, and while > using large arrays it can make a big difference in speed. > > The lesson to learn from this thread is that variables declared in a > function > as global (using global keyword) are new reference variables to the actual > global variable. And, so when these global variables in functions are > assigned > a new reference, it breaks the old reference and makes them refer to the > new > location, and the actual global variable is not affected. > But in contrast, if the global variables in the function are assigned a > new > value, this does changes the value of the variable in the outer global > scope. Well, *I* would be confused by the globals, references, and whatnot you've got running around... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php