上一篇博客 简单的 介绍了一下 命名空间的用法 今天就来给大家 简单的 介绍一下 php的全局类
全局类 名字好像很高大上 其实理解起来也非常的容易 全局类 其实就是 没有加命名空间的类
就像下面的 hello类
<?php
class hello
{
function say()
{
echo "hello world !";
}
}
调用全局类也非常容易 像这样就可以很容易的调用
<?php
require_once('test1.php');
require_once('test2.php');
require_once('hello.php');
use space\test1\test;
use space\test2\test as test2;
$test1 = new test();
$test2 = new test2();
$hello = new \hello();
$test1->say();
$test2->say();
$hello->say();