OOP
Code: Select all
<?php
//Class named Index
class Index {
protected $LinksNormal, $LinksSubOne;
public function MenuUserNormal() {
$this->linksNomal = array(
"<a href='Index.php?Action=Overview'>Overview</a>",
"<a href='Index.php'>Link Two</a>",
"<a href='Index.php'>Link Three</a>",
);
}
public function MenuUserSubOne() {
$this->LinksSubOne = array(
"<a href='Index.php?Action=Overview'>Overview</a>",
"<a href='Index.php'>Link Sub</a>",
"<a href='Index.php'>Link Two</a>",
"<a href='Index.php'>Link Three</a>",
);
}
public function GetLinksNormal() {
return $this->LinksNormal;
}
public function GetLinksSubOne() {
return $this->LinksSubOne;
}
}
?>
Code: Select all
<?php
require_once('Menu-OOP.php');
$Action = ($_GET['Action']);
If ($Action == ""){
$Action = "Home";
}
$links = New index();
If ($Action == "Home"){
echo "<br> Menu <br>";
echo implode('<br> ', $links->GetLinksNormal() );
}
ElseIf ($Action == "Overview"){
echo "<br> Menu <br>";
echo implode('<br> ', $links->GetLinksSubOne() );
}
?>
43:
echo implode('<br> ', $links->GetLinksNormal() );
I also get an error saying: Notice: Undefined index: Action in C:\wamp\www\Banner\index.php on line 5 Which means that the Get action is empty. (It is supposed to be empty the first time i get online. But how can i get "around the error"?
Hope this clarify (Or atleast help you understand better)
//Sorry for the confusion on the post before.