{"id":257514,"date":"2005-09-04T19:43:19","date_gmt":"2005-09-04T19:43:19","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/php-variable-passing-problem\/"},"modified":"2016-08-18T20:07:54","modified_gmt":"2016-08-18T20:07:54","slug":"php-variable-passing-problem","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/php-variable-passing-problem\/","title":{"rendered":"PHP variable-passing problem"},"content":{"rendered":"<p>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\/<\/p>\n<p>I keep getting this error:<br \/>\nParse error: parse error, unexpected &#8216;(&#8216;, expecting &#8216;,&#8217; or &#8216;;&#8217; in \/home\/newslett\/public_html\/wp-content\/themes\/tannaghcolors\/pdf.php on line 17<\/p>\n<p>Using the page below I set:<br \/>\n    var $HREF = get_the_content();<\/p>\n<p>***********Here&#8217;s what I inserted up top to make it work with WordPress:<\/p>\n<p>&lt;?php require(&#8216;..\/..\/..\/wp-blog-header.php&#8217;); ?&gt;<br \/>\n&lt;?php if ($posts) : foreach ($posts as $post) : start_wp(); ?&gt;<\/p>\n<p>***********Here&#8217;s the original:<\/p>\n<p>&lt;?php \/\/ -*-php-*-<br \/>\nrcs_id(&#8216;$Id: pdf.php,v 1.1.1.1 2004\/04\/13 23:41:40 braden Exp $&#8217;);<\/p>\n<p>\/\/ PDF functions taken from FPDF http:\/\/www.fpdf.org<br \/>\n\/\/ Edited for PHPWebthings by Don Seb<br \/>\n\/\/ Feel free to edit , enhance the module, and please share it at http:\/\/www.phpdbform.com<br \/>\n\/\/ Keep PHPWT COOL submit your modules\/themes\/mods, it will help to improve ! \ud83d\ude42<\/p>\n<p>require_once(&#8216;lib\/fpdf.php&#8217;);<\/p>\n<p>class PDF extends FPDF {<br \/>\n    var $B = 0;<br \/>\n    var $I = 0;<br \/>\n    var $U = 0;<br \/>\n    var $HREF = get_the_content();<\/p>\n<p>    function PDF ($orientation=&#8217;P&#8217;, $unit=&#8217;mm&#8217;, $format=&#8217;A4&#8242;) {<br \/>\n        $this-&gt;FPDF($orientation,$unit,$format);<br \/>\n    }<\/p>\n<p>    \/\/ Simple HTML to PDF converter<br \/>\n    function ConvertFromHTML($html) {<br \/>\n        $html = str_replace(&#8220;\\n&#8221;,&#8217; &#8216;,$html);<br \/>\n        $a = preg_split(&#8216;\/&lt;(.*)&gt;\/U&#8217;,$html,-1,PREG_SPLIT_DELIM_CAPTURE);<br \/>\n        foreach($a as $i=&gt;$e) {<br \/>\n            if ($i % 2 == 0) {<br \/>\n                \/\/Tekst<br \/>\n                if($this-&gt;HREF)<br \/>\n                    $this-&gt;PutLink($this-&gt;HREF,$e);<br \/>\n                else<br \/>\n                    $this-&gt;Write(5,$e);<br \/>\n            } else {<br \/>\n                \/\/Tag<br \/>\n                if ($e{0} == &#8216;\/&#8217;)<br \/>\n                    $this-&gt;CloseTag(strtoupper(substr($e,1)));<br \/>\n                else {<br \/>\n                    \/\/Filter de attributen<br \/>\n                    $a2 = explode(&#8216; &#8216;,$e);<br \/>\n                    $tag = strtoupper(array_shift($a2));<br \/>\n                    $attr = array();<br \/>\n                    foreach ($a2 as $v)<br \/>\n                        if (ereg(&#8216;^([^=]*)=[&#8220;\\&#8217;]?([^&#8221;\\&#8217;]*)[&#8220;\\&#8217;]?$&#8217;,$v,$a3))<br \/>\n                            $attr[strtoupper($a3[1])]=$a3[2];<br \/>\n                    $this-&gt;OpenTag($tag,$attr);<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/* not yet used *\/<br \/>\n    function Header() {<br \/>\n\t\/\/URL &#8211; space from side &#8211; space from top &#8211; width<br \/>\n        $imgurl = &#8220;&#8230;&#8221;; \/\/ header and wikilogo<br \/>\n        $this-&gt;Image($imgurl,3,3,$imgwidth);<br \/>\n        \/\/Line break<br \/>\n        $this-&gt;Ln(30);<br \/>\n    }<\/p>\n<p>    \/* not yet used *\/<br \/>\n    function Footer() {<br \/>\n        \/\/global $cfg, $config, $lang;<br \/>\n        \/\/Positie 1.5 cm van de onderkant<br \/>\n        $this-&gt;SetY(-15);<br \/>\n        \/\/Arial cursief 8<br \/>\n        $this-&gt;SetFont(&#8216;Arial&#8217;,&#8217;I&#8217;,8);<br \/>\n        \/\/Page number<br \/>\n        \/\/$this-&gt;Cell(0,10,$cfg[&#8220;core&#8221;][&#8220;url&#8221;],0,0,&#8217;C&#8217;);<br \/>\n        \/\/$this-&gt;Cell(0,10,&#8217; Page &#8216;.$this-&gt;PageNo().&#8217;\/{nb}&#8217;,0,0,&#8217;C&#8217;);<br \/>\n    }<\/p>\n<p>    function OpenTag($tag,$attr) {<br \/>\n        if($tag==&#8217;B&#8217; or $tag==&#8217;I&#8217; or $tag==&#8217;U&#8217;)<br \/>\n            $this-&gt;SetStyle($tag,true);<br \/>\n        if($tag==&#8217;A&#8217;)<br \/>\n            $this-&gt;HREF=$attr[&#8216;HREF&#8217;];<br \/>\n        if($tag==&#8217;BR&#8217;)<br \/>\n            $this-&gt;Ln(5);<br \/>\n    }<\/p>\n<p>    function CloseTag($tag) {<br \/>\n        if($tag==&#8217;B&#8217; or $tag==&#8217;I&#8217; or $tag==&#8217;U&#8217;)<br \/>\n            $this-&gt;SetStyle($tag,false);<br \/>\n        if($tag==&#8217;A&#8217;)<br \/>\n            $this-&gt;HREF=&#8221;;<br \/>\n    }<\/p>\n<p>    \/\/Wijzig stijl en selecteer lettertype<br \/>\n    function SetStyle($tag,$enable) {<br \/>\n        $this-&gt;$tag+=($enable ? 1 : -1);<br \/>\n        $style=&#8221;;<br \/>\n        foreach(array(&#8216;B&#8217;,&#8217;I&#8217;,&#8217;U&#8217;) as $s)<br \/>\n            if($this-&gt;$s&gt;0)<br \/>\n                $style.=$s;<br \/>\n        $this-&gt;SetFont(&#8221;,$style);<br \/>\n    }<\/p>\n<p>    function PutLink($URL,$txt) {<br \/>\n        \/\/ hyperlink as simple underlined text<br \/>\n        $this-&gt;SetTextColor(0,0,255);<br \/>\n        $this-&gt;SetStyle(&#8216;U&#8217;,true);<br \/>\n        $this-&gt;Write(5,$txt,$URL);<br \/>\n        $this-&gt;SetStyle(&#8216;U&#8217;,false);<br \/>\n        $this-&gt;SetTextColor(0);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ Local Variables:<br \/>\n\/\/ mode: php<br \/>\n\/\/ tab-width: 8<br \/>\n\/\/ c-basic-offset: 4<br \/>\n\/\/ c-hanging-comment-ender-p: nil<br \/>\n\/\/ indent-tabs-mode: nil<br \/>\n\/\/ End:<br \/>\n?&gt;<\/p>\n<p>********I inserted this to to close what I inserted up top:<\/p>\n<p> &lt;?php endforeach; ?&gt;<br \/>\n&lt;?php endif; ?&gt;<\/p>\n","protected":false},"template":"","class_list":["post-257514","topic","type-topic","status-closed","hentry","topic-tag-extend","topic-tag-pdf","topic-tag-php"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/257514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/257514\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=257514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}