当前位置: 首页>>代码示例>>PHP>>正文


PHP Str::ascii方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:sajjad-ser,项目名称:oc-persian,代码行数:23,代码来源:Persian.php

示例2: shadow

 function shadow($text)
 {
     $text = Str::ascii($text);
     $text = Str::lower($text);
     return $text;
 }
开发者ID:vegax87,项目名称:Strimoid,代码行数:6,代码来源:utils.php

示例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);
 }
开发者ID:nshontz,项目名称:laravel-blog,代码行数:24,代码来源:url.php

示例4: getFilename

 public function getFilename()
 {
     $orig = parent::getFilename();
     $orig = str_replace('%', '', $orig);
     return Str::ascii($orig);
 }
开发者ID:Lord-Simon,项目名称:MangaIndex,代码行数:6,代码来源:AsciiSafeDownloadFile.php

示例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));
 }
开发者ID:zhukangfeng,项目名称:cats,代码行数:27,代码来源:FileController.php


注:本文中的Str::ascii方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。