Jump to content

Using a variable in a function call


ghostz00

Recommended Posts

Do you mean this

[code]class example{
      var $var=100;
      var $variable=120;
}

$func1="var";
$func2="variable";

$ex=new example;

echo $ex->$func1;  // --> 100
echo $ex->$func2;  // --> 120[/code]

or this?

[code]class example{
      var $var=100;
      var $variable=120;

      function f1() {return $this->var;}
      function f2() {return $this->variable;}
}

$func1="f1";
$func2="f2";

$ex=new example;

echo $ex->$func1();  // --> 100
echo $ex->$func2();  // --> 120[/code]

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.