Hello friends,
I have problems with this:
MenuItem.class.php:
MenuBar.class.php:Code:<?php class MenuItem { var $label; var $href; var $target; function MenuItem($label="", $href="", $target="") { $this->label = $label; $this->href = $href; $this->target = $target; } function isEmpty() { return $this->label == "" && $this->href == "" && $this->target == ""; } function toString() { return "<td><a href='".$this->href."' target='".$this->target."'>".$this->label."</a></td>"; } } ?>
menu.php:Code:<?php include_once("MenuItem.class.php"); class MenuBar { var $items; function MenuBar() { $this->items = array(new MenuItem()); } function add($item) { if ($this->items[0]->isEmpty()) { $this->items[0] = $item; } else { $this->items[count($this->items)] = $item; } } function show() { $me = "<table><tr>"; $j = count($this->items); for ($i=0; $i<$j; $i++) { $me .= $this->items[$i]->toString(); } $me .= "</tr></table>"; } } ?>
The Apache return the follow error:Code:<?php include_once("../scripts/MenuBar.class.php"); $menu = new MenuBar(); $menu->add("Google", "http://www.google.co.cr/", "_blank"); $menu->show(); ?>
Fatal error: Call to a member function on a non-object in /home/iconco/public_html/invent/scripts/MenuBar.class.php on line 25
Can Helpme??




Reply With Quote