本文整理汇总了PHP中ConfigFile::preload方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFile::preload方法的具体用法?PHP ConfigFile::preload怎么用?PHP ConfigFile::preload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::preload方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Query the config for a scope/variable. Returns the first value or scope on success,
* or mDefault (default: null) if the query was not found.
* @param string $sQuery The query string. e.g. "variable", "scope", "scope.variable", etc
* @param mixed $mDefault The return value should the query not find anything.
* @return string|ConfigFile|null The matching value from the query, or mDefault if not found
*/
public function get($sQuery, $mDefault = null)
{
$mVal = $mDefault;
# try to get value match first
if (array_key_exists($sQuery, $this->aValues) && count($this->aValues[$sQuery]) > 0) {
$mVal = $this->aValues[$sQuery][0];
} else {
# check if this matches any scopes
$sScopeChar = preg_quote($this->sScopeDelimiter, "/");
$sQueryStr = preg_quote($sQuery, "/");
# must match a scope exactly ( "my.scope" should not match "my.scopeless" )
$sScopePattern = "/^{$sQueryStr}{$sScopeChar}(.+)\$/";
$aScopeMatches = array();
foreach ($this->aValues as $sName => $mValue) {
if (preg_match($sScopePattern, $sName, $aMatch) === 1) {
$aScopeMatches[$aMatch[1]] = $mValue;
}
}
if (count($aScopeMatches) > 0) {
$mVal = new ConfigFile();
$mVal->preload($aScopeMatches);
}
}
return $mVal;
}