Last active
June 27, 2020 14:45
-
-
Save fahidjavid/ba14452295e12a2dc07c633fc0bc53d0 to your computer and use it in GitHub Desktop.
Explains the way we can use **namespace** in PHP.   { | |
echo "Hello from first class file."; | |
} | |
} |
This file contains hidden or 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 second; | |
use second\A as AC; | |
require_once( 'first-class.php' ); | |
require_once( 'second-class.php' ); | |
$object = new AC; // Renamed class from A class under 'second' namespace. | |
$object = new \A; // To use as global (first file class). |
This file contains hidden or 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 second; | |
class A { | |
public function __construct() { | |
echo "Hello from second class file."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment