类的名称,PHP5返回的结果是区分大小写的
- <?php
- class base_class
- {
- function say_a()
- {
- echo "'a' - said the " . __CLASS__ . "<br/>";
- }
- function say_b()
- {
- echo "'b' - said the " . get_class($this) . "<br/>";
- }
- }
- class derived_class extends base_class
- {
- function say_a()
- {
- parent::say_a();
- echo "'a' - said the " . __CLASS__ . "<br/>";
- }
- function say_b()
- {
- parent::say_b();
- echo "'b' - said the " . get_class($this) . "<br/>";
- }
- }
- $obj_b = new derived_class();
- $obj_b->say_a();
- echo "<br/>";
- $obj_b->say_b();
- ?>
- 结果为:
- 'a' - said the base_class
- 'a' - said the derived_class
- 'b' - said the derived_class
- 'b' - said the derived_class