Guest User

Untitled

a guest
Jan 24th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <?php
  2. class Foo{
  3. /...
  4. public static fonction getClassName(){
  5. return static::class;
  6. }
  7. /...
  8. }
  9. Foo::getClassName(); // return "Foo"
  10. ?>
  11.  
  12. class Foo{
  13.  
  14. static get className(){ return "Foo";}
  15.  
  16. // ...
  17. // ...
  18.  
  19. }
  20.  
  21. Foo.className(); // get the hardcoded "Foo"
  22.  
  23. class Foo{
  24.  
  25. static get className(){ return someJavascriptAlreadyWayForGetClassName() ;}
  26.  
  27. // ...
  28. // ...
  29.  
  30. }
  31. Foo.classCame(); // get "Foo"
  32.  
  33. function Foo() {}
  34.  
  35. var fooInstance = new Foo();
  36. console.log(fooInstance.constructor.name); // logs "Foo"
Add Comment
Please, Sign In to add comment