Re: Import symbol table into function' scope.

From: Date: Wed, 15 Jun 2011 16:05:37 +0000
Subject: Re: Import symbol table into function' scope.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-313550@lists.php.net to get a copy of this message
2011/6/15 Дмитрий Степанов <dmitrij@stepanov.lv> > So I wonder if there is any way to import scope (symbol table) into the > method DBReader::readSomething()? > Since you're using call_user_func_array() to call your internal methods already (just to expose protected methods publicly?), you could add $DB as a parameter. public function __call($method, $args) { array_unshift($args, $this->DB); return call_user_func_array( array( $this, $method), $args); } protected function readSomething($DB) { $DB->query(...); $DB->numRows(); ... } I would advise getting used to the $this-> everywhere. I can from Java where that's not required but don't really mind it anymore. However, the above would work and be automatic once you added the parameter to each method. Peace, David

« previous php.general (#313550) next »