fork download
  1. <?php
  2.  
  3. abstract class Render
  4. {
  5.  
  6. abstract public function main();
  7.  
  8. public function __construct()
  9. {
  10.  
  11. }
  12.  
  13. final public function render()
  14. {
  15. if (!$this->canRender()) return null;
  16.  
  17. return $this->main();
  18. }
  19.  
  20. final public function canRender()
  21. {
  22. // Logic here
  23. return true;
  24. }
  25. }
  26.  
  27. class AdminPanel extends Render
  28. {
  29. public function main()
  30. {
  31. return "Admin Panel";
  32. }
  33. }
  34.  
  35. $panel = new AdminPanel();
  36.  
  37. echo $panel->render();
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Admin Panel