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
  • 37,789
  • 41
  • 162
  • 229

1 Answers1

1

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

Husman
  • 6,579
  • 7
  • 28
  • 46