I am trying to educate myself with the functions of PHP 5.3 / PHP 5.4 OOP.
I tried to code something like this. However, this does not work.
index.php
namespace Website; use Website\Database as Database; class Website extends Database { function __construct() { echo "Test"; } } $website = new Website();
./Site/database.php
namespace Website\Database; class Database { function construct() { echo "Hello from Database"; } }
I know how to create classes, bind them to each other, etc., but every time I add a namespace to the beginning, everything gets broken.
So, I would like to ask a few elementary things:
Q1 : use ClassName; Does it automatically load / enable a class?
Q2 : which means \ without any action on the left side. (e.g. new \ Database ();)
Q3 : Does \ directory mean in PHP, or is it just how developers view it as?
Q4 : What changes should be made in my script to make it work?
source share