title: PHP - multiple function return TCPDF variables
body: <p>I have lot of code for creating pdf (TCPDF) separate by header, body, footer...
  and I need to call the code as needed with variable coordinates. Because I need use <code>if else</code> calls are (of course) multiple and needlessly I rewrite the same code.</p>
  
  <p>For example I try this (subheader):</p>
  
  <pre><code>class invoice {
     function getSubheader($disY){
        $subheader = array(
           $pdf-&gt;SetLineWidth(.2),
           $pdf-&gt;MultiCell(190,9,'',1,'L',false,0,10,$disY,true),
           $pdf-&gt;SetFont('freesans','',7),
           $pdf-&gt;MultiCell(50,"",$getDesc['blabla1'],0,'L',false,0,12,$disY+2,true),
           $pdf-&gt;MultiCell(15,"",$getDesc['blabla2'],0,'R',false,0,62,$disY+2,true),
           $pdf-&gt;MultiCell(20,"",$getDesc['blabla3'],0,'R',false,0,77,$disY+2,true),
           $pdf-&gt;MultiCell(15,"",$getDesc['blabla4'],0,'R',false,0,97,$disY+2,true),
           $pdf-&gt;MultiCell(25,"",$getDesc['blabla5'],0,'R',false,0,112,$disY+2,true),
           $pdf-&gt;MultiCell(15,"",$getDesc['blabla6'],0,'R',false,0,137,$disY+2,true),
           $pdf-&gt;MultiCell(20,"",$getDesc['blabla7'],0,'R',false,0,152,$disY+2,true),
           $pdf-&gt;MultiCell(25,"",$getDesc['blabla8'],0,'R',false,0,172,$disY+2,true),   
           $pdf-&gt;SetFont('freesans','B',8),
           $pdf-&gt;MultiCell(180,"",$getDesc['blabla9'],0,'L',false,0,12,$disY+11,true)
        );
  
        return $subheader;
     }
  
     others functions...
  }
  </code></pre>
  
  <p>In another <code>class</code> call only a <code>function</code></p>
  
  <pre><code>$pdf = new TCPDF (PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  $pdf-&gt;AddPage();
  
  lot of code $pdf-&gt;...
  
  $invoice = new invoice();
  
  if(cond == 1){
     $disY = 100;
     $invoice-&gt;getSubheader($disY);
  } else {
     $disY = 200;
     $invoice-&gt;getSubheader($disY);
  }
  
  lot of code $pdf-&gt;...    
  </code></pre>
  
  <p>This <code>function</code> must return variables $pdf->SetLineWidt... etc.
  But if I use this solution - error</p>
  
  <pre><code>Call to a member function SetLineWidth() on null
  </code></pre>
  
  <p>Any advice for a newbie?</p>