您应该检查每行的列值,
  
  #Create the table
function BasicTable($header,$data) {
    #Create the header.
    foreach ($header as $col)
        $this->Cell(18,5,$col,1);
    $this->Ln();
    #Get the data
    foreach ($data as $row) {
        $cnt = 0;
        foreach ($row as $col) {
            if($cnt < 2){
              $this->Cell(18,5,$col,1,'R');
            }
            else {
              $this->Cell(18,5, $col, 1, 0); 
            }
            $cnt++;
        }
     $this->Ln();   
     }
}
  
   我还在函数中发现了额外的“}”。
  
  
   根据上述帖子更新代码
  
  #Create the table
    function BasicTable($header,$data) {
        #Create the header.
        foreach ($header as $col)
            $this->Cell(18,5,$col,1);
            $this->Ln();
            #Get the data
    foreach ($data as $row) {
        $cnt = 0;
        foreach ($row as $col) {
            if($cnt < 2){
              $this->Cell(18,5,$col,1);
            }
            else {
              $this->Cell(18,5, $col, 1, 0,'R'); 
            }
            $cnt++;
        }
     $this->Ln();   
     }
        }
    }