View Single Post
  #7  
Old 02-06-2009, 02:38 AM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
Quote:
Originally Posted by Loriel View Post
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(barbaz)
{ ... }

Foo(12true999); 
bar would equal 1, and baz would equal 2. However, the params array looks like this:

PHP Code:
{12true999
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];

__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote