self_static - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of self_static.php

  1. <?php
  2.  
  3. abstract class A
  4. {
  5.     const TEST = "test";
  6.     
  7.     abstract public static function testFunc();
  8.     
  9.     public function testFunc2()
  10.     {
  11.         return self::TEST."_".static::testFunc();
  12.     }
  13. }
  14.  
  15. class B extends A
  16. {
  17.     public function accessConst()
  18.     {
  19.         return self::TEST;
  20.     }
  21.     
  22.     public static function testFunc()
  23.     {
  24.         return "Document";
  25.     }
  26. }
  27.  
  28. $b = new B();
  29. echo $b->testFunc2();
  30. //echo $b->accessConst();
  31.  
  32.  
File Description
  • self_static
  • PHP Code
  • 22 Dec-2022
  • 447 Bytes
You can Share it: