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 8997423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:53:15+00:00 2026-06-15T23:53:15+00:00

If I have a System folder in the root directory containing a Database folder

  • 0

If I have a System folder in the root directory containing a Database folder with a Database.php file which holds a class

class Database{
   static function Connect(){
      echo "connect";
   }
}

And I call that from an index.php which is in the root directory.

How do I make a namespace to access the class Database::Connect();
I really am struggling with namespaces.

Do I need to put namespace System\Database at the top of my Database.php file or something? Any good examples that aren’t on php.net pages?

  • 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-15T23:53:16+00:00Added an answer on June 15, 2026 at 11:53 pm

    Namespaces (in PHP) are really just a way of preventing naming collisions between Classes in a project. They have been used for a some time (before they were officially supported) in the form of classes named things like “Zend_Controller_Action_Helper”.
    The PHP5.3 introduction of “real” namespaces really just means we can now use short, readable names in our code by “use”ing a namespace.

    eg.

    file: system/database.php

    namespace MyProject;
    
    class Database {
    // ...
    }
    

    file public/index.php

    require_once '../system/database.php';
    
    // here we have to use the fully qualified name of the Database class,
    // this is similar to the old unofficial underscore method.
    $db = \MyProject\Database::connect();
    

    file: public/index2.php

    require_once '../system/database.php';
    use MyProject\Database;
    
    // here we can simply use "Database" because the "use" statement says:
    // for this file we are using the "Database" class from the "MyProject" namespace
    $db = Database::connect();
    

    Namespaces are only related to directories by convention (and for autoloading) they, in an of themselves, don’t change the way classes are included and used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file located in my CakePHP root folder placed under a folder
I have a test solution (TestSolutionA) which contains a test project (TestProjectA: containing system
We have system here that uses Java JNI to call a function in a
Let's say we have system A comprising a MySQL database, with several tables. After
I have a system which is receiving log files from different places through http
I've got moved the Application and System folders below the root directory as described
I have a directory and I want to allow users which are only logged
I have directory with following structure root temp User_related_folder preview1.jpg preview2.jpg preview3.jpg I need
I have the following function that loops through a directory and checks for a
I have a directory in the root of my codeigniter application called /css it

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.