Welcome Guest, Not a member yet? Register   Sign In
How to use a variable in: $this->index(); ?
#3

[eluser]mddd[/eluser]
The first example should work:
Code:
$page = 'index';
$this->$page();  // this calls $this->index();

Is this literally what you are doing? If you use class properties, it's a bit different:
Code:
class Someclass()
{
   var $page = 'index';

   function index()
   {
      // hello
   }
  
   function callpage()
   {
      $this->{$this->page}();   // this calls $this->index()
   }
}


Messages In This Thread
How to use a variable in: $this->index(); ? - by El Forum - 04-15-2010, 02:09 AM
How to use a variable in: $this->index(); ? - by El Forum - 04-15-2010, 02:23 AM
How to use a variable in: $this->index(); ? - by El Forum - 04-15-2010, 02:29 AM
How to use a variable in: $this->index(); ? - by El Forum - 04-15-2010, 02:35 AM
How to use a variable in: $this->index(); ? - by El Forum - 04-15-2010, 02:43 AM
How to use a variable in: $this->index(); ? - by El Forum - 04-15-2010, 03:03 AM
How to use a variable in: $this->index(); ? - by El Forum - 04-15-2010, 03:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB