Created
January 10, 2020 10:06
-
-
Save quimo/5862b37ebc3b4e7bac39e7caff038ec8 to your computer and use it in GitHub Desktop.
PHP Namespaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace IFQ\project1; | |
class Project { | |
public function __construct() { | |
printf("Project1\n"); | |
} | |
} | |
printf("namespaces/project1/project1.php\n"); | |
$demo = new Project(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace IFQ\project2; | |
class Project { | |
public function __construct() { | |
printf("Project2\n"); | |
} | |
} | |
printf("namespaces/project1/project1.php\n"); | |
$demo = new Project(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'project1/project1.php'; | |
include 'project2/project2.php'; | |
printf("namespaces/projects.php\n"); | |
$project = new IFQ\project1\Project(); | |
$project = new IFQ\project2\Project(); | |
use IFQ\project1\Project as Progetto; | |
use IFQ\project2\Project; | |
$project = new Progetto(); // Project1 | |
$project = new Project(); // Project2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment