init() 공개 정적인 메소드

Cookie初始化
public static init ( array $config = [] ) : void
$config array
리턴 void
예제 #1
0
 /**
  * Cookie管理
  * @param string|array  $name cookie名称,如果为数组表示进行cookie设置
  * @param mixed         $value cookie值
  * @param mixed         $option 参数
  * @return mixed
  */
 function cookie($name, $value = '', $option = null)
 {
     if (is_array($name)) {
         // 初始化
         Cookie::init($name);
     } elseif (is_null($name)) {
         // 清除
         Cookie::clear($value);
     } elseif ('' === $value) {
         // 获取
         return 0 === strpos($name, '?') ? Cookie::has(substr($name, 1), $option) : Cookie::get($name);
     } elseif (is_null($value)) {
         // 删除
         return Cookie::delete($name);
     } else {
         // 设置
         return Cookie::set($name, $value, $option);
     }
 }
예제 #2
0
파일: helper.php 프로젝트: yuhongjie/think
function cookie($name, $value = '')
{
    if (is_array($name)) {
        // 初始化
        \think\Cookie::init($name);
    } elseif (is_null($name)) {
        // 清除
        \think\Cookie::clear($value);
    } elseif ('' === $value) {
        // 获取
        return \think\Cookie::get($name);
    } elseif (is_null($value)) {
        // 删除session
        return \think\Cookie::delete($name);
    } else {
        // 设置session
        return \think\Cookie::set($name, $value);
    }
}
예제 #3
0
 public function testInit()
 {
     $config = ['prefix' => 'think_', 'expire' => 0, 'path' => '/path/to/test/', 'domain' => '.thinkphp.cn', 'secure' => true, 'httponly' => '1'];
     \think\Cookie::init($config);
     $this->assertEquals(array_merge($this->default, array_change_key_case($config)), $this->ref->getValue());
 }