php8.5
Home/ Manual/ yaf / yaf_config_simple/ Yaf_Config_Simple::offsetExists

Yaf_Config_Simple::offsetExists

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Check if a key exists (ArrayAccess)

Description

Yaf_Config_Simple::offsetExists(mixed $name): bool

Checks whether a configuration key exists. This method is an alias of Yaf_Config_Simple::__isset and is called when isset() is used with array syntax on a configuration object.

Parameters

name

The configuration key to check.

Return Values

Returns true if the key exists, false otherwise.

Examples

Yaf_Config_Simple::offsetExists example

php
<?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']));
?>

The above example will output something similar to:

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

See Also

  • Yaf_Config_Simple::get
  • Yaf_Config_Simple::__isset

Source: reference/yaf/yaf_config_simple/offsetexists.xml · from the official PHP manual (php/doc-en)