8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

クラス名を取得する

Posted at

意外に今まで使わなかったな。メモメモ。
ちょっとPHPでプラグインを作成している時に利用しました。

<?php
class foo {
    function name()
    {
        echo "Classs name is " , get_class($this) , "\n";
    }
}
// オブジェクトを生成
$bar = new foo();

// 内部から呼ぶ場合。
$bar->name();

// 外部からも呼べる。
echo "Class name is " , get_class($bar) , "\n";
?>

❏PHP Manual
http://php.net/manual/ja/function.get-class.php

8
9
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?