Title: PHP variable-passing problem
Last modified: August 18, 2016

---

# PHP variable-passing problem

 *  [joelwalsh](https://wordpress.org/support/users/joelwalsh/)
 * (@joelwalsh)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/php-variable-passing-problem/)
 * This is a page of PHP (not from WordPress but somewhere else) to convert a post
   into a PDF. You can see it here, in the PDF link in the right-hand box: [http://upmarketnewsletters.com/articles/sticky-post-2/](http://upmarketnewsletters.com/articles/sticky-post-2/)
 * I keep getting this error:
    Parse error: parse error, unexpected ‘(‘, expecting‘,’
   or ‘;’ in /home/newslett/public_html/wp-content/themes/tannaghcolors/pdf.php 
   on line 17
 * Using the page below I set:
    var $HREF = get_the_content();
 * ***********Here’s what I inserted up top to make it work with WordPress:
 * <?php require(‘../../../wp-blog-header.php’); ?>
    <?php if ($posts) : foreach(
   $posts as $post) : start_wp(); ?>
 * ***********Here’s the original:
 * <?php // -*-php-*-
    rcs_id(‘$Id: pdf.php,v 1.1.1.1 2004/04/13 23:41:40 braden
   Exp $’);
 * // PDF functions taken from FPDF [http://www.fpdf.org](http://www.fpdf.org)
    //
   Edited for PHPWebthings by Don Seb // Feel free to edit , enhance the module,
   and please share it at [http://www.phpdbform.com](http://www.phpdbform.com) //
   Keep PHPWT COOL submit your modules/themes/mods, it will help to improve ! 🙂
 * require_once(‘lib/fpdf.php’);
 * class PDF extends FPDF {
    var $B = 0; var $I = 0; var $U = 0; var $HREF = get_the_content();
 *  function PDF ($orientation=’P’, $unit=’mm’, $format=’A4′) {
    $this->FPDF($orientation,
   $unit,$format); }
 *  // Simple HTML to PDF converter
    function ConvertFromHTML($html) { $html = str_replace(“\
   n”,’ ‘,$html); $a = preg_split(‘/<(.*)>/U’,$html,-1,PREG_SPLIT_DELIM_CAPTURE);
   foreach($a as $i=>$e) { if ($i % 2 == 0) { //Tekst if($this->HREF) $this->PutLink(
   $this->HREF,$e); else $this->Write(5,$e); } else { //Tag if ($e{0} == ‘/’) $this-
   >CloseTag(strtoupper(substr($e,1))); else { //Filter de attributen $a2 = explode(‘‘,
   $e); $tag = strtoupper(array_shift($a2)); $attr = array(); foreach ($a2 as $v)
   if (ereg(‘^([^=]*)=[“\’]?([^”\’]*)[“\’]?$’,$v,$a3)) $attr[strtoupper($a3[1])]
   =$a3[2]; $this->OpenTag($tag,$attr); } } } }
 *  /* not yet used */
    function Header() { //URL – space from side – space from
   top – width $imgurl = “…”; // header and wikilogo $this->Image($imgurl,3,3,$imgwidth);//
   Line break $this->Ln(30); }
 *  /* not yet used */
    function Footer() { //global $cfg, $config, $lang; //Positie
   1.5 cm van de onderkant $this->SetY(-15); //Arial cursief 8 $this->SetFont(‘Arial’,’
   I’,8); //Page number //$this->Cell(0,10,$cfg[“core”][“url”],0,0,’C’); //$this-
   >Cell(0,10,’ Page ‘.$this->PageNo().’/{nb}’,0,0,’C’); }
 *  function OpenTag($tag,$attr) {
    if($tag==’B’ or $tag==’I’ or $tag==’U’) $this-
   >SetStyle($tag,true); if($tag==’A’) $this->HREF=$attr[‘HREF’]; if($tag==’BR’)
   $this->Ln(5); }
 *  function CloseTag($tag) {
    if($tag==’B’ or $tag==’I’ or $tag==’U’) $this->SetStyle(
   $tag,false); if($tag==’A’) $this->HREF=”; }
 *  //Wijzig stijl en selecteer lettertype
    function SetStyle($tag,$enable) { $this-
   >$tag+=($enable ? 1 : -1); $style=”; foreach(array(‘B’,’I’,’U’) as $s) if($this-
   >$s>0) $style.=$s; $this->SetFont(”,$style); }
 *  function PutLink($URL,$txt) {
    // hyperlink as simple underlined text $this-
   >SetTextColor(0,0,255); $this->SetStyle(‘U’,true); $this->Write(5,$txt,$URL);
   $this->SetStyle(‘U’,false); $this->SetTextColor(0); } }
 * // Local Variables:
    // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-
   comment-ender-p: nil // indent-tabs-mode: nil // End: ?>
 * ********I inserted this to to close what I inserted up top:
 *  <?php endforeach; ?>
    <?php endif; ?>

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [davidchait](https://wordpress.org/support/users/davidchait/)
 * (@davidchait)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/php-variable-passing-problem/#post-258036)
 * I could be wrong but:
    var $HREF = get_the_content(); looks like the line in 
   question, and I believe ‘var’ statements can only be assigned a constant. So 
   you need to assign get_the_content(); at some later point most likely.
 * -d
 *  Thread Starter [joelwalsh](https://wordpress.org/support/users/joelwalsh/)
 * (@joelwalsh)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/php-variable-passing-problem/#post-258105)
 * Thanks! Where should I try moving get_the_content() to?
 * As you can see, I know nothing about php but this was supposed to be a pretty
   easy script.
 *  [masquerade](https://wordpress.org/support/users/masquerade/)
 * (@masquerade)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/php-variable-passing-problem/#post-258106)
 * David isn’t exactly correct, var can take a variable also. Can you pastebin the
   pdf file somewhere so that we can more easily see exactly which line the problem
   is on?
 *  Thread Starter [joelwalsh](https://wordpress.org/support/users/joelwalsh/)
 * (@joelwalsh)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/php-variable-passing-problem/#post-258107)
 * What is pastebin?
 *  Thread Starter [joelwalsh](https://wordpress.org/support/users/joelwalsh/)
 * (@joelwalsh)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/php-variable-passing-problem/#post-258108)
 * wait, I think this is the general idea with paste-bin, to see the php:
 * [http://upmarketnewsletters.com/wp-content/themes/tannaghcolors/pdf.php.txt](http://upmarketnewsletters.com/wp-content/themes/tannaghcolors/pdf.php.txt)

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘PHP variable-passing problem’ is closed to new replies.

## Tags

 * [extend](https://wordpress.org/support/topic-tag/extend/)
 * [pdf](https://wordpress.org/support/topic-tag/pdf/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 5 replies
 * 3 participants
 * Last reply from: [joelwalsh](https://wordpress.org/support/users/joelwalsh/)
 * Last activity: [20 years, 9 months ago](https://wordpress.org/support/topic/php-variable-passing-problem/#post-258108)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
