本文整理汇总了PHP中Str::ascii方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::ascii方法的具体用法?PHP Str::ascii怎么用?PHP Str::ascii使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Str
的用法示例。
在下文中一共展示了Str::ascii方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fixValidations
public function fixValidations()
{
CmsPage::extend(function ($page) {
$page->rules['url'] = ['required', 'regex:/^\\/[۰-۹آا-یa-z0-9\\/\\:_\\-\\*\\[\\]\\+\\?\\|\\.\\^\\\\$]*$/iu'];
});
//edit blog url validation rule
if (PluginManager::instance()->exists('rainlab.blog')) {
\RainLab\Blog\Models\Post::extend(function ($post) {
$post->rules['slug'] = ['required', 'regex:/^[۰-۹آا-یa-z0-9\\/\\:_\\-\\*\\[\\]\\+\\?\\|]*$/iu', 'unique:rainlab_blog_posts'];
});
}
//extending rainlab.pages
if (PluginManager::instance()->exists('rainlab.pages')) {
//edit rainlab page url validation rule
\RainLab\Pages\Classes\Page::extend(function ($page) {
$page->rules['url'] = ['required', 'regex:/^\\/[۰-۹آا-یa-z0-9\\/_\\-]*$/iu', 'uniqueUrl'];
});
//edit rainlab page filename in crating
\RainLab\Pages\Classes\Page::creating(function ($page) {
$page->fileName = \Str::ascii($page->fileName);
}, -1);
}
}
示例2: shadow
function shadow($text)
{
$text = Str::ascii($text);
$text = Str::lower($text);
return $text;
}
示例3: slug
/**
* Generate a URL friendly "slug".
*
* <code>
* // Returns "this-is-my-blog-post"
* $slug = URL::slug('This is my blog post!');
*
* // Returns "this_is_my_blog_post"
* $slug = URL::slug('This is my blog post!', '_');
* </code>
*
* @param string $title
* @param string $separator
* @return string
*/
public static function slug($title, $separator = '-')
{
$title = Str::ascii($title);
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$title = preg_replace('![^' . preg_quote($separator) . '\\pL\\pN\\s]+!u', '', Str::lower($title));
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $title);
return trim($title, $separator);
}
示例4: getFilename
public function getFilename()
{
$orig = parent::getFilename();
$orig = str_replace('%', '', $orig);
return Str::ascii($orig);
}
示例5: downloadByFileId
/**
* Download the file by file id.
*
* @param int $id
* @return Response
*/
public function downloadByFileId($file_id)
{
//
$file = DownloadFile::file($file_id);
$real_path = storage_path() . $file->save_path;
$headers = array('Content-Type:' . $file->type);
// return $file->save_path;
$realFile = $real_path . DIRECTORY_SEPARATOR . $file->save_name;
$response = new Response();
// return $response->download($realFile, $file->real_name, $headers);
// echo iconv('UTF-8', 'ASCII', $realFile);
$realFile = mb_convert_encoding($realFile, 'ASCII');
// exit;
// return response()->download(iconv('UTF-8', 'ASCII', $realFile), $file->real_name, $headers);
return Response::download($realFile, $file->real_name, $headers);
$response = new BinaryFileResponse($file, 200, $headers, true);
if (is_null($name)) {
$name = basename($file);
}
return $response->setContentDisposition($disposition, $name, Str::ascii($name));
}