本文整理汇总了PHP中Properties::getBool方法的典型用法代码示例。如果您正苦于以下问题:PHP Properties::getBool方法的具体用法?PHP Properties::getBool怎么用?PHP Properties::getBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Properties
的用法示例。
在下文中一共展示了Properties::getBool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetBool
function testGetBool()
{
global $UBAR_GLOB;
$path = $UBAR_GLOB['UBAR_ROOT'] . "test" . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "sample.properties";
$pathToPropertiesClass = $UBAR_GLOB['UBAR_ROOT'] . "core" . DIRECTORY_SEPARATOR . "Properties.php";
$props = new Properties($path);
// test valid
$this->assertEquals(TRUE, $props->getBool("sample.boolean"));
// test unable to convert (other errors covered in test_get()
try {
$props->getBool("sample.badboolean");
$this->fail("Expected exception trying to get property you can't convert to bool.");
} catch (Exception $e) {
$value = $props->get("sample.badboolean");
$expectedMessage = "The property found, " . $value . ", with the key \"sample.badboolean\" could not be converted to a boolean value in the file \"{$path}\".";
$this->assertEquals($expectedMessage, $e->getMessage());
}
}
示例2: Properties
$props = new Properties($UBAR_GLOB['UBAR_CONFIG_OVERRIDE'], true);
} else {
$props = new Properties($UBAR_GLOB['UBAR_ROOT'] . "ubar_config.properties", true);
}
# DEFINE CONSTANTS FROM PROPERTIES FILE
/**
* Define DEV_MODE, defaulting to the value found in DEV_MODE if not set.
* NOTE: This must be defined prior to other defines due to their values
* switching on DEV_MODE
*
* NOTE: Some test classes may define this before init script loaded.
*
* @see GlobalConstants::DEV_MODE
*/
if (!isset($UBAR_GLOB['DEV_MODE'])) {
$UBAR_GLOB['DEV_MODE'] = $props->getBool('DEV_MODE', GlobalConstants::DEV_MODE);
}
/**
* Define a property appender based on dev mode to simplify the dev mode value
* retrieval
*/
$UBAR_GLOB['PROP_APPEND'] = $UBAR_GLOB['DEV_MODE'] ? '_DEV_MODE' : '';
/**
* Define the default locale.
* @see GlobalConstants::LOCALE_DEFAULT
*/
$UBAR_GLOB['LOCALE_DEFAULT'] = $props->get('LOCALE_DEFAULT', GlobalConstants::LOCALE_DEFAULT);
/**
* Define display errors flag.
* @see GlobalConstants::DISPLAY_ERRORS
*/