本文整理汇总了PHP中YDConfig::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP YDConfig::exists方法的具体用法?PHP YDConfig::exists怎么用?PHP YDConfig::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YDConfig
的用法示例。
在下文中一共展示了YDConfig::exists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDefault
function actionDefault()
{
// Set some variables
YDConfig::set('MyConfigVar1', 'value cfg1');
YDConfig::set('MyConfigVar2', 'value cfg2');
YDConfig::set('MyConfigVar3', 'value cfg3');
// Get the values
YDDebugUtil::dump(YDConfig::get('MyConfigVar1'), 'get - MyConfigVar1');
YDDebugUtil::dump(YDConfig::get('MyConfigVar2'), 'get - MyConfigVar2');
YDDebugUtil::dump(YDConfig::get('MyConfigVar3'), 'get - MyConfigVar3');
// Check if the variables exist or not
YDDebugUtil::dump(YDConfig::exists('MyConfigVar1'), 'exists - MyConfigVar1');
YDDebugUtil::dump(YDConfig::exists('MyConfigVar2'), 'exists - MyConfigVar2');
YDDebugUtil::dump(YDConfig::exists('MyConfigVar3'), 'exists - MyConfigVar3');
// Check an unexisting variable
YDDebugUtil::dump(YDConfig::exists('xx'), 'exists - xx');
// Set some variables, not overriding existing values
YDConfig::set('MyConfigVar1', 'value cfg1 changed', false);
YDConfig::set('MyConfigVar2', 'value cfg2 changed', false);
YDConfig::set('MyConfigVar3', 'value cfg3 changed', false);
// Get the values (should be unchanged)
YDDebugUtil::dump(YDConfig::get('MyConfigVar1'), 'get - MyConfigVar1 - changed1');
YDDebugUtil::dump(YDConfig::get('MyConfigVar2'), 'get - MyConfigVar2 - changed1');
YDDebugUtil::dump(YDConfig::get('MyConfigVar3'), 'get - MyConfigVar3 - changed1');
// Set some variables, overriding existing values
YDConfig::set('MyConfigVar1', 'value cfg1 changed', true);
YDConfig::set('MyConfigVar2', 'value cfg2 changed', true);
YDConfig::set('MyConfigVar3', 'value cfg3 changed', true);
// Get the values (should be changed)
YDDebugUtil::dump(YDConfig::get('MyConfigVar1'), 'get - MyConfigVar1 - changed2');
YDDebugUtil::dump(YDConfig::get('MyConfigVar2'), 'get - MyConfigVar2 - changed2');
YDDebugUtil::dump(YDConfig::get('MyConfigVar3'), 'get - MyConfigVar3 - changed2');
// Dump the contents of YDConfig
YDConfig::dump();
}
示例2: get
/**
* This function returns a variable from the configuration. If the configuration variable doesn't exist, it
* returns a fatal error.
*
* @param $name The name of the configuration variable to retrieve.
*
* @returns The value of the configuration variable.
*/
function get($name)
{
// Raise an error if an invalid configuration setting
if (!YDConfig::exists($name)) {
trigger_error('Configuration variable "' . $name . '" is not defined.', YD_ERROR);
}
// Return the value
return $GLOBALS[YD_CONFIG_VAR][$name];
}
示例3: get
/**
* This function returns a variable from the configuration. If the configuration variable doesn't exist, it
* returns a fatal error.
*
* @param $name The name of the configuration variable to retrieve.
* @param $default (optional) If not null, this value will be returned if the configuration setting doesn't
* exist in the configuration.
*
* @returns The value of the configuration variable.
*/
function get($name, $default = null)
{
return YDConfig::exists($name) ? $GLOBALS[YD_CONFIG_VAR][$name] : $default;
}
示例4: get
/**
* This function returns a variable from the configuration. If the configuration variable doesn't exist, it
* returns a fatal error.
*
* @param $name The name of the configuration variable to retrieve.
* @param $default (optional) If not null, this value will be returned if the configuration setting doesn't
* exist in the configuration.
*
* @returns The value of the configuration variable.
*/
function get($name, $default = null)
{
// Check if the key exists
if (!YDConfig::exists($name)) {
// Return the default
return $default;
}
// Return the value
return $GLOBALS[YD_CONFIG_VAR][$name];
}