Yaf_Session::offsetExists

(Yaf >=1.0.0)

Yaf_Session::offsetExists检查会话键是否存在(ArrayAccess)

说明

public function Yaf_Session::offsetExists(mixed $name): bool

检查会话键是否存在。此方法是 Yaf_Session::has() 的别名,在以数组方式使用 isset() 时会被调用。

参数

name

要检查的会话键。

返回值

键存在时返回 true,否则返回 false

示例

示例 #1 Yaf_Session::offsetExists() 示例

<?php
$session = Yaf_Session::getInstance();
$session->start();

$session["user_id"] = 42;

var_dump(isset($session["user_id"]));
var_dump(isset($session["user_name"]));
?>

以上示例的输出类似于:

bool(true)
bool(false)

参见