oop - PHP: get_called_class() vs get_class($this) -


in php difference between get_called_class() , get_class($this) when used inside instance?

example:

class {     function dump() {         echo get_called_class();         echo get_class($this);     } }  class b extends {}  $a = new a(); $b = new b();  $a->dump(); // output 'aa' $b->dump(); // output 'bb' 

is there difference in case?

when should using 1 or other get_called_class() or get_class($this)?

in case there's no difference, because $this points correct instance class name resolved using get_class().

the function get_called_class() intended static methods. when static methods overridden, function return class name provides context current method that's being called.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -