aaaa - 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 aaaa.php

  1. <?php
  2.  
  3. class MenuElement
  4. {
  5.     public $id;
  6.     public $children = array();
  7.  
  8.     public __construct($id)
  9.     {
  10.         $this->id = $id;
  11.     }
  12.  
  13.     public function addChild(MenuElement $menuElement)
  14.     {
  15.         array_push($this->children, $menuElement);
  16.     }
  17. }
  18.  
  19. $menuElement1    = new MenuElement(1);
  20. $menuElement11   = new MenuElement(11);
  21. $menuElement12   = new MenuElement(12);
  22. $menuElement121  = new MenuElement(121);
  23. $menuElement122  = new MenuElement(122);
  24. $menuElement123  = new MenuElement(123);
  25. $menuElement1211 = new MenuElement(1211);
  26.  
  27. $menuElement121->addChild($menuElement1211);
  28. $menuElement12->addChild($menuElement121);
  29. $menuElement12->addChild($menuElement122);
  30. $menuElement12->addChild($menuElement123);
  31. $menuElement1->addChild($menuElement11);
  32. $menuElement1->addChild($menuElement12);
  33.  
  34.  
File Description
  • aaaa
  • PHP Code
  • 18 Aug-2019
  • 838 Bytes
You can Share it: