Quote:
Originally Posted by Loriel
Could you elaborate on the magic?
Edit: Uh, how do I even call that function to make params[0] actually hold a value?
|
params[] is set to the total sum of the variables passed into a function. Consider the following:
PHP Code:
function Foo(bar, baz)
{ ... }
Foo(1, 2, true, 999);
bar would equal 1, and baz would equal 2. However, the params array looks like this:
PHP Code:
{1, 2, true, 999}
And thus, the above function can literally be transcribed into:
PHP Code:
function Foo()
{
bar = params[0];
baz = params[1];
}
This is not dissimilar to C#'s implementation of parameters, if you're into that:
PHP Code:
// C#
private void Foo(params object[] parameters)
{
var bar = parameters[0];
var baz = parameters[1];
}