2011-12-01 3 views
0

클래스 외부에서 함수를 설정하거나 더 좋은 방법이 있습니까?클래스 및 확장

는 내가 기록 된 데이터가 변수 높이를 가지고 있기 때문에 나는 Header()를 사용할 수 없습니다 .. 각 페이지의 상단에 뭔가를 작성해야 당신이하려고하는 것을 아주 확실하지 않다

require_once 'tcpdf/tcpdf.php'; 

class TCPDF_ext extends TCPDF { 
    public function AcceptPageBreak(){ 
     $this->AddPage(); 
     $this->lastpage(); 
     $this->add_top(); 

     return false; 
    } 
} 

$pdf = new TCPDF_ext(); 

$pdf->add_top = function(){ 
    // write something on the top of each page 
}; 

답변

0

그래도 작동하지 않을까?

require_once 'tcpdf/tcpdf.php'; 

class TCPDF_ext extends TCPDF { 
    public function AcceptPageBreak(){ 
     $this->AddPage(); 
     $this->lastpage(); 
     $this->add_top(); 

     return false; 
    } 
    protected function add_top(){ 
     //write stuff to page top 
    } 
} 

$pdf = new TCPDF_ext(); 
$pdf->AcceptPageBreak()