passing vars...<

liunx

Guest
Hrm, ok if i want to pass a variable to a function.. i know how to do that.. BUT if that function is going to use the variable NAME AND VALUE, how do i access each of those? $$? &? ${} ?

i.e

function doot($k)
{
hum[name] = // code to put the var name in it
hum[value] = // code to put the value of the var in it
}


plz hlp, kthx

-flfunction doot($k)
{
$k[name] = value // code to put the var name in it

}


doot($array);

the name always carries the value. if you are talking arrays then yes, but regualr variables don't have a namethat's not exactly what i meant..

like.. ok
say i wrote a class and i want to have a register in it

i.e

class sessionclass { ....
function reg($k) {
$_SESSION[//what goes here] = $k;
global //what goes here;
}
}

so i can just be all like

$doot = "hello world";

sessionclass->reg($doot);


-flname it whatever you want.

function reg($k) {
$_SESSION['$k'] = $k;
$_GLOBALS['$k'] = $k; //what goes here;
}

you have to hard code it if you want different names
 
Back
Top