TestAction.php
上传用户:shuoshiled
上传日期:2018-01-28
资源大小:10124k
文件大小:1k
源码类别:

中间件编程

开发平台:

JavaScript

  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. }