0

With this code:

<?php

class a {
  public static function type() {
    echo get_class();
  }
}

class b extends a {
}

echo b::type();

It outputs a. I would like the name of the calling class: b. Is it possible ?

Benjamin Crouzier
  • 40,265
  • 44
  • 171
  • 236

1 Answers1

1

If you are running PHP 5.3 or higher: get_called_class() will do the job

Husman
  • 6,819
  • 9
  • 29
  • 47