You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
858 B

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. class TestAction {
  3. function doEcho($data){
  4. return $data;
  5. }
  6. function multiply($num){
  7. if(!is_numeric($num)){
  8. throw new Exception('Call to multiply with a value that is not a number');
  9. }
  10. return $num*8;
  11. }
  12. function getTree($id){
  13. $out = array();
  14. if($id == "root"){
  15. for($i = 1; $i <= 5; ++$i){
  16. array_push($out, array(
  17. 'id'=>'n' . $i,
  18. 'text'=>'Node ' . $i,
  19. 'leaf'=>false
  20. ));
  21. }
  22. }else if(strlen($id) == 2){
  23. $num = substr($id, 1);
  24. for($i = 1; $i <= 5; ++$i){
  25. array_push($out, array(
  26. 'id'=>$id . $i,
  27. 'text'=>'Node ' . $num . '.' . $i,
  28. 'leaf'=>true
  29. ));
  30. }
  31. }
  32. return $out;
  33. }
  34. }