Home >Backend Development >PHP Tutorial >PHP get_class() function

PHP get_class() function

巴扎黑
巴扎黑Original
2016-11-22 09:24:261179browse

<?php
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>";
?>

Output result:

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


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn