mgph Posted November 16, 2009 Share Posted November 16, 2009 Hi, I'm having this error Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION It's indicating that the error is at line 6(at the first starting line inside the class), but when I commented that indicated line out, it shows the very next line, again and again. Here are my code <?php class Page { // attributes $content; $title = "Someone Teach Me"; $keywords = "anyone can teach you, something you can learn here"; $buttons = array("Home" => "home.php", "Contact" => "contact.php", "Services" => "services.php", "Site Map" => "sitemap.php" ); function __set($name,$value) { $this->$name = $value; } function Display() { echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n <html xmlns=\"http://www.w3.org/1999/xhtml\">\n <head>"; $this->DisplayTitle(); $this->DisplayKeywords(); $this->DisplayStyles(); echo "</head>\n<body>\n"; $this->DisplayHeader(); $this->DisplayMenu($this->buttons); echo $this->content; $this->DisplayFooter(); echo "</body>\n</html>\n"; } function DisplayTitle() { echo "<title>".$this->title."</title>"; } function DisplayKeywords() { echo "<meta name=\"keywords\" content=\"".$this->keywords."\" />"; } function DisplayStyles() { echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"_css/backbone.css\" />"; } function DisplayHeader() { //TODO : add banner & text echo "<div id=\"masthead\">masthead</div>"; } function DisplayMenu($buttons) { ?> <div id="mainNav"> <ul> <li><a href="#" class="active firstList">Home</a></li> <li><a href="#">Games</a></li> <li><a href="about.html">About</a></li> <li><a href="#">References</a></li> <li class="lastList"><a href="#">Sitemap</a></li> </ul> </div> <?php } function DisplayFooter() { //TODO : add footer here } function IsURLCurrentPage($url) { if (strpos($_SERVER['PHP_SELF'], $url) == false) return false; else return true; } } ?> I use it as a template and I get this syntax error when I call from other .php file. please can someone help me find where is it and how to fix it! thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/181739-help-me-find-syntax-error-please/ Share on other sites More sharing options...
rajivgonsalves Posted November 16, 2009 Share Posted November 16, 2009 you forgot the "var" keyword <?php class Page { // attributes var $content; var $title = "Someone Teach Me"; var $keywords = "anyone can teach you, something you can learn here"; var $buttons = array("Home" => "home.php", "Contact" => "contact.php", "Services" => "services.php", "Site Map" => "sitemap.php" ); function __set($name,$value) { $this->$name = $value; } function Display() { echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n <html xmlns=\"http://www.w3.org/1999/xhtml\">\n <head>"; $this->DisplayTitle(); $this->DisplayKeywords(); $this->DisplayStyles(); echo "</head>\n<body>\n"; $this->DisplayHeader(); $this->DisplayMenu($this->buttons); echo $this->content; $this->DisplayFooter(); echo "</body>\n</html>\n"; } function DisplayTitle() { echo "<title>".$this->title."</title>"; } function DisplayKeywords() { echo "<meta name=\"keywords\" content=\"".$this->keywords."\" />"; } function DisplayStyles() { echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"_css/backbone.css\" />"; } function DisplayHeader() { //TODO : add banner & text echo "<div id=\"masthead\">masthead</div>"; } function DisplayMenu($buttons) { ?> <div id="mainNav"> <ul> <li><a href="#" class="active firstList">Home</a></li> <li><a href="#">Games</a></li> <li><a href="about.html">About</a></li> <li><a href="#">References</a></li> <li class="lastList"><a href="#">Sitemap</a></li> </ul> </div> <?php } function DisplayFooter() { //TODO : add footer here } function IsURLCurrentPage($url) { if (strpos($_SERVER['PHP_SELF'], $url) == false) return false; else return true; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/181739-help-me-find-syntax-error-please/#findComment-958538 Share on other sites More sharing options...
mgph Posted November 17, 2009 Author Share Posted November 17, 2009 yeah, it solved like a magic Thanks buddy Quote Link to comment https://forums.phpfreaks.com/topic/181739-help-me-find-syntax-error-please/#findComment-958816 Share on other sites More sharing options...
MadTechie Posted November 17, 2009 Share Posted November 17, 2009 Please click topic solved (button at the bottom left) Quote Link to comment https://forums.phpfreaks.com/topic/181739-help-me-find-syntax-error-please/#findComment-958820 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.