<?php class myclass { //状态:取消 const STATUS_ABORT = -1; //状态:签约 const STATUS_SIGN = 0; //状态:执行 const STATUS_ATTEND = 1; //定义一个返回数组的函数 public static function statusArray(){ return array( self::STATUS_ABORT => '取消', self::STATUS_SIGN => '签约', self::STATUS_ATTEND => '执行', ); } //根据状态码转文字 public static function statusDecode($status_num){ $reval = ''; $t = self::statusArray(); return $t[(string)(intval($status_num) ? intval($status_num) : self::STATUS_ABORT)]; } } echo myclass::statusDecode(-1); ?>
运行结果是:取消