Forum Moderators: coopster

Message Too Old, No Replies

very basic function question

         

doozer77

5:19 pm on Jun 16, 2005 (gmt 0)

10+ Year Member



I am very new to php and am confused by this one thing:

in all function I've seen so far there are a set of parentheses. As I've read, arguments are to be placed here. But in all the real world examples I've come across there is never anything inside those parentheses.


function [i]function_name[/i] () {
[i]statements;[/i]
}

What exactly would an argument be and why have I not yet seen one?

sned

5:40 pm on Jun 16, 2005 (gmt 0)

10+ Year Member



Arguments are the things that go inside the ():

function multiply($var1, $var2){
return ($var1 * $var2);
}

This would be called like this:

$x = multiply(2,4);

2 & 4 being the arguments.

$x would equal 8 after calling that function.

Probably not the best example, but I hope it helps

-sned