PHP get_class()函数调用示例

发布时间:2019-12-25编辑:脚本学堂
本文介绍下,php中取得类实例信息的函数get_class的用法示例,有需要的朋友参考下吧。

php中get_class()函数的用法举例。

例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
/**
* 学习get_class的用法
* edit by www.jb200.com
*/
class Foo { 
    function name_none_static(){ 
        echo "My name is " . get_class() . "<br>"
        echo "My name is " . get_class($this) . "<br>"
    
   
//类内部调用 
$bar = new Foo(); 
$bar->name_none_static(); 
   
//类外部调用 
echo "Its name is " . get_class($bar) . "<br>"
?>

输出结果:

My name is Foo
My name is Foo
Its name is Foo
28