So I have two php classes, one is a class, one uses the other, my class is:
(menu.php)
<?php
public class Menu
{
$home = '<li><a href="index.html"><span>Home</span></a></li>';
$home_selected = '<li class="navhome"><a href="index.html"><span>Home</span></li>';
$projects = '<li><a href=""><span>Projects</span></a></li>';
$projects_selected = '<li class="navhome"><a href=""><span>Projects</span></a></li>';
$contact = '<li><a href=""><span>Contact Us</span></a></li>';
$contact_selected = '<li class="navhome"><a href=""><span>Contact Us</span></a></li>';
public function getMyMenu($value)
{
switch($value) {
case "home":
return (string) $home_selected . $projects . $contact;
break;
case "projects":
return $home . $projects_selected . $contact;
break;
case "contact":
return $home . $projects . $contact_selected;
break;
}
}
}
?>
however, in index.php, where ever
<?php include("menu.php");
$menu = new Menu();
echo($menu->getMyMenu("home")); ?>
or any variation of this is put, the web page just wont load after that, for example if it is put in the middle of the page, the end of the page isn’t even sent to the browser.
I’m very new to php, and I’m hoping this is a “duh” answer, if you need more please ask; thanks
you should quote (
'or") the stringfull code: