I am trying to create a custom class and have an array of those objects and I can't seem to get it to work. Here is my code:
class NavigationItem
{
private $_filename;
private $_linkname;
public function __construct($filename, $linkname)
{
parent::__construct();
$this->_filename = $filename;
$this->_linkname = $linkname;
}
public function getFilename()
{
return $_filename;
}
public function getLinkname()
{
return $_linkname;
}
}
$navInfo = array();
$size = array_push($navInfo, new NavigationItem("index.php","HOME"),
new NavigationItem("about.php","ABOUT"),
new NavigationItem("coaches.php","STAFF"),
new NavigationItem("summer.php","SUMMER 2011"),
new NavigationItem("fall.php","FALL 2011"),
new NavigationItem("history.php","HISTORY"),
new NavigationItem("contact.php","CONTACT"));
echo "<table>";
echo "<tr>";
echo "<td colspan=\"7\" height=\"125px\"><img src=\"images/banner_blue_skinny.jpg\" alt=\"\" /></td>";
echo "</tr>";
echo "<tr>";
for($i=0; $i<$size; $i++)
{
echo "<td class=\"linkCell\"><a class=\"navigation\" href=\"" . $navInfo[$i]->getFilename() . "\">" . $navInfo[$i]->getLinkname() . "</a></td>";
}
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"7\" class=\"gapCell\"></td>";
echo "</tr>";
echo ""; echo "";
Any ideas?
parent::__construct();? You don't inherit from one?