How to use make call another namespace without using include?

0

I see developers at all times using the "use" command under the "namespace" command without first using an include.

An example is the Medoo library:

namespace Medoo;

use PDO;
use Exception;
use PDOException;

class Raw {
    public $map;
    public $value;
}

How does this work? I try to do the same but it never works.

Look at my example and explain to me, please, what's wrong:

Directories:

App
|
+--- MyspaceA
|       |
|       +--- MyclassA.php
|
+--- MyspaceB
|       |
|       +--- MyclassB.php
|
+--- index.php

MyclassA.php:

<?php namespace MyspaceA;

    class MyclassA {
        public static $myvarA = "Ola Mundo";
    }

?>

MyclassB.php:

<?php namespace MyspaceB;

    use MyspaceA\MyclassA;

    class MyclassB {
        public static $myvarB = "!!!!!";
    }

    $myvarC = MyclassA::$myvarA + MyclassB::$myvarB;

?>

index.php:

<?php 

include("MyspaceA/MyclassA.php");
include("MyspaceB/MyclassB.php");

echo($myvarC);

?>

The result I expected:

Ola Mundo!!!!!

But it makes a mistake!

What's wrong with my code?

    
asked by anonymous 01.09.2018 / 03:53

0 answers