Exemple #1
0
 /**
  * 获取提交的参数(包含get,post等方式)<br/>
  * 参数为null则为判断是否有post提交
  * @param string $pam 参数名称
  * @param mixed $default 如果不存在请求内容则为传入的默认值,此值可以为闭包函数
  * @return mixed 参数值 字串或数组
  */
 public static function obtain($pam = null, $default = null)
 {
     if ($pam === null) {
         return count($_REQUEST) > 0;
     }
     if (!isset($_REQUEST[$pam])) {
         return $default === null ? false : YYUC::value($default);
     }
     if (is_string($_REQUEST[$pam])) {
         return get_magic_quotes_gpc() ? stripslashes($_REQUEST[$pam]) : $_REQUEST[$pam];
     } else {
         if (is_array($_REQUEST[$pam])) {
             if (get_magic_quotes_gpc()) {
                 $res_arr = array();
                 foreach ($_REQUEST[$pam] as $res) {
                     $res_arr[] = stripslashes(trim($res));
                 }
                 $_REQUEST[$pam] = $res_arr;
             }
             return $_REQUEST[$pam];
         }
     }
 }
Exemple #2
0
 /**
  * 读取文件内容.
  *
  * @param  string  $path
  * @param  mixed   $default 默认值
  * @return string
  */
 public static function get($path, $default = null)
 {
     return file_exists($path) ? file_get_contents($path) : YYUC::value($default);
 }
Exemple #3
0
 /**
  * 页面级缓存读取
  */
 public static function get($k, $default = null)
 {
     if (isset($_SERVER['YYUC_PTEMP' . $k])) {
         return $_SERVER['YYUC_PTEMP' . $k];
     }
     return $default === null ? false : YYUC::value($default);
 }