Skip to content

Instantly share code, notes, and snippets.

@fahidjavid
Last active June 27, 2020 14:45
Show Gist options
  • Save fahidjavid/ba14452295e12a2dc07c633fc0bc53d0 to your computer and use it in GitHub Desktop.
Save fahidjavid/ba14452295e12a2dc07c633fc0bc53d0 to your computer and use it in GitHub Desktop.
<?php
class A {
public function __construct() {
echo "Hello from first class file.";
}
}
<?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).
<?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