& Sign in Functions

Hi all, I’ve seen a couple of times in a few scripts and seen the & sign in a function (and I think I also saw it in an if statement). Tried Googling it but find very little! Any help would be appreciated :smiley:

function example(& $var)

Take a look at these:



Hey Force Flow, that’s perfect, massive help, cheers bud :smiley:

Passing by reference should be avoided whenever possible - it creates extremely hard to debug code when you have functions that modify their argument in addition to giving their return. Use references to save memory, but if you do pass an argument by reference do NOT modify it in the function. Ignore this warning at your peril because if you abuse references eventually you’ll end up with code that is almost impossible to debug.

They should be used with caution, yes. But they do have their benefits in certain situations.