Skip to content

Instantly share code, notes, and snippets.

@olehi94
Last active January 9, 2019 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olehi94/a12aa9d0a473086289cece5654051af3 to your computer and use it in GitHub Desktop.
Save olehi94/a12aa9d0a473086289cece5654051af3 to your computer and use it in GitHub Desktop.
Example using namespaces.
<?php
use Lib\Eddard as AnotherEddard;
class Eddard {
public static function whoAmI() {
return 'It\'s method whoAmI in index.php.';
}
}
require_once 'lib.php';
$edd1 = new Eddard();
echo $edd1::whoAmI() . '<br>';
$edd2 = new AnotherEddard();
echo $edd2::whoAmI();
<?php
namespace Lib;
class Eddard {
public static function whoAmI() {
return 'It\'s method whoAmI in lib1.php.';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment