本文整理汇总了PHP中str::urlify方法的典型用法代码示例。如果您正苦于以下问题:PHP str::urlify方法的具体用法?PHP str::urlify怎么用?PHP str::urlify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类str
的用法示例。
在下文中一共展示了str::urlify方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
static function fetch($file)
{
if (!file_exists($file)) {
return array();
}
$content = f::read($file);
$content = str_replace("", '', $content);
$sections = preg_split('![\\r\\n]+[-]{4,}!i', $content);
$data = array();
foreach ($sections as $s) {
$parts = explode(':', $s);
if (count($parts) == 1 && count($sections) == 1) {
return $content;
}
$key = str::urlify($parts[0]);
if (empty($key)) {
continue;
}
$value = trim(implode(':', array_slice($parts, 1)));
$data[$key] = $value;
}
return $data;
}
示例2: safe_name
/**
* Sanitize a filename to strip unwanted special characters
*
* @param string $string The file name
* @return string
*/
static function safe_name($string)
{
return str::urlify($string);
}
示例3: write
static function write($file, $values)
{
if (file_exists($file) && !is_writable($file)) {
return array('status' => 'error', 'msg' => l::get('writer.errors.permissions'));
}
$break = false;
$result = "";
$keys = array();
foreach ($values as $k => $v) {
$k = str::urlify($k);
$k = str::ucfirst(str_replace('-', '_', $k));
if (in_array($k, $keys) || empty($k)) {
continue;
}
$keys[] = $k;
$result .= $break . $k . ': ' . trim($v);
$break = "\n\n----\n\n";
}
@chmod(basename($file), 0666);
$write = f::write($file, $result);
if (!$write || !file_exists($file)) {
return array('status' => 'error', 'msg' => l::get('writer.errors.write'));
}
return array('status' => 'success', 'msg' => l::get('writer.success'));
}
示例4: elseif
</h1>
<nav>
<?php
$company = $page->company();
if ($company == 'Isle of Wight') {
?>
<a rel="up" href="/regions/england/isle-of-wight">Isle of Wight</a>
<?php
} elseif ($company == 'London') {
?>
<a rel="up" href="/regions/england/london">London</a>
<?php
} else {
?>
<a rel="up" href="/companies/<?php
echo preg_replace('/-railway$/', '', str::urlify($page->company()));
?>
"><?php
echo smartypants($page->company());
?>
</a>
<?php
}
?>
</nav>
</header>
<?php
if ($page->text != "") {
?>
<div class="e-content prose">