本文整理匯總了PHP中StringHelper::basename方法的典型用法代碼示例。如果您正苦於以下問題:PHP StringHelper::basename方法的具體用法?PHP StringHelper::basename怎麽用?PHP StringHelper::basename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類StringHelper
的用法示例。
在下文中一共展示了StringHelper::basename方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildXml
/**
* @see yii\web\XmlResponseFormatter::buildXml()
*/
protected function buildXml($element, $data)
{
if (is_object($data)) {
$child = new DOMElement(StringHelper::basename(get_class($data)));
$element->appendChild($child);
if ($data instanceof Arrayable) {
$this->buildXml($child, $data->toArray());
} else {
$array = [];
foreach ($data as $name => $value) {
$array[$name] = $value;
}
$this->buildXml($child, $array);
}
} elseif (is_array($data)) {
foreach ($data as $name => $value) {
if (is_int($name) && is_object($value)) {
$this->buildXml($element, $value);
} elseif (is_array($value) || is_object($value)) {
$child = new DOMElement(is_int($name) ? $this->itemTag : $name);
$element->appendChild($child);
$this->buildXml($child, $value);
} else {
$child = new DOMElement(is_int($name) ? $this->itemTag : $name);
$element->appendChild($child);
$child->appendChild(new DOMText((string) $value));
}
}
} else {
$element->appendChild(new DOMText((string) $data));
}
}
示例2: tableName
/**
* 支持分表散列獲取表名
* @return string
*/
public static function tableName()
{
return '{{%' . Inflector::camel2id(StringHelper::basename(get_called_class()), '_') . '}}' . static::shardTableRule();
}
示例3: basename
public static function basename($class)
{
$class = static::getClass($class);
return StringHelper::basename($class);
}