php get_class()函數

<?php  
  
class Car {  
      
    function getName(){  
        echo "My name is " . get_class() . "<br>";  
        echo "My name is " . get_class($this) . "<br>";  
    }  
}  
  
//類內部調用  
$bar = new Car();  
$bar->getName();  
  
//類外部調用  
echo "Its name is " . get_class($bar) . "<br>";  
  
?>   

運行結果php

My name is Carthis

My name is Car
Its name is Car
spa

相關文章
相關標籤/搜索