1

簡単にするために、これが私のページの設定方法です。

class TFS extends PHP_db
{
    public function execute() {
        class Dostuff {
            public static function doit() {
                return "wee";
            }
        }
    Now here I can use Dostuff:doit() successfully
    And also $this->db->functionhere() which is from the PHP_db is also successful from here

    }
}

Dostuff クラス$this->db->functionhere()内の関数内から呼び出す方法を理解する必要があります。doit()

私はすでに Dostuff クラスでこれを試しました:

protected $parent_object;
public function __construct( $object ) {
    $this->parent_object = $object;
 }

そして、これは execute() 関数から:$dostuffclass = new Dostuff($this);

しかし、それを使おうとする$parent_object->db->functionhere()と、オブジェクトではないと言ってうまくいきません。

4

1 に答える 1