當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。