本文主要和大家分享php全局类实例介绍,希望能帮助到大家。
就像下面的 hello类
<?phpclass hello{
function say()
{
echo "hello world !";
}
}调用全局类也非常容易 像这样就可以很容易的调用
<?phprequire_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();在 new 关键字 实例化类前 在类名前加 \ 就可以实例化全局类
以上就是php全局类实例介绍的详细内容,更多请关注Gxl网其它相关文章!