本文整理汇总了PHP中CString::endsWith方法的典型用法代码示例。如果您正苦于以下问题:PHP CString::endsWith方法的具体用法?PHP CString::endsWith怎么用?PHP CString::endsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::endsWith方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storageUnitFromOptionValue
protected static function storageUnitFromOptionValue($optionValue)
{
$optionValue = CString::toLowerCase($optionValue);
if (CString::endsWith($optionValue, "k")) {
return CUUnit::KILOBYTE;
}
if (CString::endsWith($optionValue, "m")) {
return CUUnit::MEGABYTE;
}
if (CString::endsWith($optionValue, "g")) {
return CUUnit::GIGABYTE;
}
if (CString::endsWith($optionValue, "t")) {
return CUUnit::TERABYTE;
}
return CUUnit::BYTE;
}
示例2: add
/**
* Adds a path component to a path, separating them with a slash if needed, and returns the combined path.
*
* If the specified path component already starts with "/", it still results in a single "/" as the separator. And,
* as a special case, if the base path is empty, the returned string is the same as the specified path component.
*
* @param string $basePath The base path (can be absolute or relative).
* @param string $component The path component to be added to the base path (cannot be absolute).
*
* @return CUStringObject The combined path.
*/
public static function add($basePath, $component)
{
assert('is_cstring($basePath) && is_cstring($component)', vs(isset($this), get_defined_vars()));
assert('!CString::isEmpty($component)', vs(isset($this), get_defined_vars()));
if (CString::isEmpty($basePath)) {
return $component;
}
if (!CString::endsWith($basePath, "/")) {
$basePath .= "/";
}
return $basePath . $component;
}
示例3: speak
/**
* Echoes a message into the output and, if logging is enabled, into the log file, adding a space after the
* message's text unless the message is already ending in a space.
*
* @param string $message The message to be echoed.
* @param bool $writeToLog **OPTIONAL. Default is** `true`. If logging is enabled, tells whether the message
* should also be written to the log file.
*
* @return void
*/
public static function speak($message, $writeToLog = true)
{
assert('is_cstring($message) && is_bool($writeToLog)', vs(isset($this), get_defined_vars()));
if (!CString::endsWith($message, " ")) {
$message .= " ";
}
echo $message;
if ($writeToLog && isset(self::$ms_logFp)) {
self::writeToLog($message);
}
}