Jump to content

[SOLVED] Passing Vars to Funtions


siwelis

Recommended Posts

global

 

Variables set inside a function are available only to that function. Vars set outside that function are only available to items outside functions.

 

You need to look in the manual regarding the scope of variables.

$var1=4;
$var2=3;
$var3=6;

function Test(){
global $var1,$var2,$var3;
echo $var1+$var2+$var3;
}

Test();

 

This returns 13

 

If you drop out the global, those variables are not available inside the function.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.