Yaconf::has
Check whether a configuration value exists
Description
public static bool Yaconf::has(string $name)
Determines whether a configuration value exists under
name, which uses the same dot notation as
Yaconf::get: for example, "app.name"
or, since Yaconf 1.2.0, "users.database.master" for
files in sub-directories.
Parameters
-
name
-
The configuration name to look up, using dot notation to
traverse nested keys, for example
"app.name"
or "users.database.master".
Return Values
Returns true if a configuration value exists at
name, false otherwise.
Examples
The examples below assume an app.ini placed
in the directory configured with yaconf.directory,
holding the keys name="shop" and
debug=0.
Example #1 Yaconf::has example
<?php
var_dump(Yaconf::has("app.name")); // bool(true)
var_dump(Yaconf::has("app.missing")); // bool(false)
// useful to distinguish a stored empty value from a missing key,
// where Yaconf::get() would return the same default for both
if (Yaconf::has("app.debug")) {
$debug = (bool) Yaconf::get("app.debug");
}
?>
See Also
- Yaconf::get
- Yaconf::__debug_info