PHP 8.6.0 Beta 3 is available for testing

Yaf_Config_Simple::offsetExists

(Yaf >=1.0.0)

Yaf_Config_Simple::offsetExists检查键是否存在(ArrayAccess)

说明

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

检查配置键是否存在。此方法是 Yaf_Config_Simple::__isset() 的别名,当对配置对象以数组方式使用 isset() 时会被调用。

参数

name

要检查的配置键。

返回值

如果键存在返回 true,否则返回 false

示例

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

<?php
$config = new Yaf_Config_Simple([
    'application' => ['name' => 'MyApp'],
    'database'    => ['host' => 'localhost'],
]);

var_dump(isset($config['database']));
var_dump($config->offsetExists('database'));
var_dump(isset($config['cache']));
?>

以上示例的输出类似于:

bool(true)
bool(true)
bool(false)

参见

添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top