{"id":6,"date":"2008-07-19T08:15:09","date_gmt":"2008-07-19T12:15:09","guid":{"rendered":"http:\/\/www.compdigitec.com\/labs\/?p=6"},"modified":"2012-06-26T08:51:55","modified_gmt":"2012-06-26T13:51:55","slug":"stopping-syntax-error-expecting-t_function","status":"publish","type":"post","link":"http:\/\/www.compdigitec.com\/labs\/2008\/07\/19\/stopping-syntax-error-expecting-t_function\/","title":{"rendered":"Stopping syntax error, unexpected &#8216;;&#8217;, expecting T_FUNCTION"},"content":{"rendered":"<p>If you&#8217;ve ever been stumped by &#8220;Parse error: syntax error, unexpected &#8216;;&#8217;, expecting T_FUNCTION&#8221;, you will know that this is a very difficult bug to track. Fortunately, we have found the error for you.<\/p>\n<p>This error message is very misleading, because your actual problem is that you have an extra semi-colon at the end of your functions, like the one below (see line 12):<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\/\/ Demo Syntax Error Example\r\n\/\/ Public domain\r\n\r\nclass Demo {\r\n     var $a;\r\n     var $b;\r\n\r\n     function problem_here() {\r\n          $this-&gt;a = 'Hello World!';\r\n     }; # &lt;-- That one\r\n};\r\n?&gt;\r\n<\/pre>\n<p>Now, the above code looks good, but when you try to run it it PHP spits out the following parse error:<\/p>\n<blockquote><p>Parse error: syntax error, unexpected &#8216;;&#8217;, expecting T_FUNCTION in *.php on line *<\/p><\/blockquote>\n<p>So, to fix it, simply remove the offending semi-colon at the end of your functions. Hope this helped anyone who got stuck with this misleading PHP error.<\/p>","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve ever been stumped by &#8220;Parse error: syntax error, unexpected &#8216;;&#8217;, expecting T_FUNCTION&#8221;, you will know that this is a very difficult bug to track. Fortunately, we have found the error for you. This error message is very misleading, because your actual problem is that you have an extra semi-colon at the end of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/6"}],"collection":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":0,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}