Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8008225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:04:17+00:00 2026-06-04T18:04:17+00:00

So I have two php classes, one is a class, one uses the other,

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:04:19+00:00Added an answer on June 4, 2026 at 6:04 pm

    you should quote (' or ") the string

    $home = '<li><a href="index.html"><span>Home</span></a></li>';
    

    full code:

    class Menu
    {
        private $home = '<li><a href="index.html"><span>Home</span></a></li>';
        private $home_selected = '<li class="navhome"><a href="index.html"><span>Home</span></li>';
    
        private $projects = '<li><a href=""><span>Projects</span></a></li>';
        private $projects_selected = '<li class="navhome"><a href=""><span>Projects</span></a></li>';
    
        private $contact = '<li><a href=""><span>Contact Us</span></a></li>';
        private $contact_selected = '<li class="navhome"><a href=""><span>Contact Us</span></a></li>';
    
        public function getMyMenu($value)
        {
            switch($value) {
                case "home":
                    return $this->home_selected . $this->projects . $this->contact;
                    break;
                case "projects":
                    return $this->home . $this->projects_selected . $this->contact;
                    break;
                case "contact":
                    return $this->home . $this->projects . $this->contact_selected;
                    break;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes in a PHP application, B extending A for example. Class
Here's the objective. I have a PHP class and there are one or two
I have this code (two classes) class url { private $profile_id; private $short; public
Can I extend a PHP class from two classes, one of which is abstract
I have two classes, one of them is a configuration class. Inside of this
I have two PHP classes. One is for connecting to the database, building queries,
I have a file with a class Resp . The path is: C:\xampp\htdocs\One\Classes\Resp.php And
I have two PHP apps which have twho class with the same name. -
I am confused with & and && . I have two PHP books. One
I have two folders php and perl . They contain index.php and index.pl ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.