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

PHP get_class() function

巴扎黑
Release: 2016-11-22 09:24:26
Original
1162 people have browsed it

<?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>";
?>
Copy after login

Output result:

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template