Maison >développement back-end >tutoriel php >php get_class()函数,phpget_class函数_PHP教程

php get_class()函数,phpget_class函数_PHP教程

WBOY
WBOYoriginal
2016-07-13 10:04:36783parcourir

php get_class()函数,phpget_class函数

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

运行结果

My name is Car

My name is Car
Its name is Car

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/965026.htmlTechArticlephp get_class()函数,phpget_class函数 ? php class Car { function getName(){ echo "My name is " . get_class () . "br" ; echo "My name is " . get_class ( $this ) . "br" ; } } //...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn