PHP bir sınıftan başka referans bir değişken kullanarak

0 Cevap

işte benim kod sürümü aşağı bir kesim bulunuyor:

class lookAClass
{
 public $pageTitle;

 public function add()
 {
  $tmp = 'just some filler text <[pageTitle]> and some more text';
  echo preg_replace_callback('<\<\[(.*)\]\>>', array(&$this, 'parseAdd'), $tmp);
 }

 private function parseAdd($matches)
 {
  return $this->$matches[1];
 }


}

$main = new lookAClass();

$main->add();

Yani temelde ne yapmaya çalışıyorum "<[pageTitle]>" değiştirin $ this-> pageTitle ile

I $this->$matches[1] yanlış olduğunu biliyorum ama ben bağlantıyı yapmak için nasıl bulmak için görünmüyor olabilir.

0 Cevap