當前位置: 首頁>>代碼示例>>PHP>>正文


PHP YDConfig::exists方法代碼示例

本文整理匯總了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();
 }
開發者ID:BackupTheBerlios,項目名稱:ydframework-svn,代碼行數:35,代碼來源:config.php

示例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];
 }
開發者ID:BackupTheBerlios,項目名稱:ydframework-svn,代碼行數:17,代碼來源:YDConfig.php

示例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;
 }
開發者ID:BackupTheBerlios,項目名稱:ydframework-svn,代碼行數:14,代碼來源:YDF2_init.php

示例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];
 }
開發者ID:BackupTheBerlios,項目名稱:ydframework-svn,代碼行數:20,代碼來源:YDF2_core.php


注:本文中的YDConfig::exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。