$value) { $clone->$key = $value; } return $clone; } /** * 对象装箱 * @param type $surObj 原始obj * @param type $desObj 具体obj */ static function loadObject($surObj, &$desObj) { if($surObj==null||$desObj==null) return; foreach ($desObj as $key => $value) { if (property_exists($surObj, $key)) { $desObj->$key = $surObj->$key; } } } /** * 对象装箱 * @param type $obj * @param type $type * @return type */ static function loadClass($obj, $type){ $newObj = new $type(); self::loadObject($obj, $newObj); return $obj; } /** * 数组装箱 * @param type $obj * @param type $type * @return type */ static function loadArray($obj, $type){ $array = array(); foreach($obj as $item){ $array[] = self::loadClass($item, $type); } return $array; } /** * 字典装箱 * @param type $obj * @param type $type * @return \stdClass */ static function loadDict($obj, $type){ $dict = new stdClass(); foreach($obj as $key=>$val){ $dict->$key = self::loadClass($val, $type); } return $dict; } /** * 方法调用 * @param type $func * @param type $paras * @param type $class */ static function callFunction($func, $paras, $class=""){ if($class == "" || $class == null){ call_user_func_array($func, $paras); }else{ call_user_func_array(array($class, $func), $paras); } } /** * 浮点数转整形 * @param type $value * @return type */ static function floatToInt($value){ return round($value - 0.4999); } /** * 浮点数转上整形 * @param type $value * @return type */ static function floatToCeil($value){ return round($value + 0.4999); } /** * 解析异常描述信息 * @param type $e * @return type */ static function getExceptMsg($e) { return 'Msg:'.$e->getMessage().' Code:'.$e->getCode().' File:'.$e->getFile().' Line:'.$e->getLine(); } /** * 提取url参数 * @param type $querryStr * @return type */ static function getQuerryParas($querryStr) { $arr = explode("&", $querryStr); $querryParas = array(); foreach ($arr as $value) { $paras = explode("=", $value); $querryParas[$paras[0]] = $paras[1]; } return $querryParas; } /** * 获取客户端ip地址及端口 * @return type */ static function getClientEP(){ return $_SERVER['REMOTE_ADDR'].":".$_SERVER['REMOTE_PORT']; } }