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


PHP Str::ascii方法代码示例

本文整理汇总了PHP中Illuminate\Support\Str::ascii方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::ascii方法的具体用法?PHP Str::ascii怎么用?PHP Str::ascii使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Str的用法示例。


在下文中一共展示了Str::ascii方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * @param string $name
  * @param int $size
  * @param string $background_color
  * @param string $text_color
  * @param string $font_file
  * @return ImageManagerStatic
  * @throws Exception
  */
 public static function create($name = '', $size = 512, $background_color = '#666', $text_color = '#FFF', $font_file = '../../../font/OpenSans-Semibold.ttf')
 {
     if (strlen($name) <= 0) {
         throw new Exception('Name must be at least 2 characters.');
     }
     if ($size <= 0) {
         throw new Exception('Input must be greater than zero.');
     }
     if ($font_file === '../../../font/OpenSans-Semibold.ttf') {
         $font_file = __DIR__ . "/" . $font_file;
     }
     if (!file_exists($font_file)) {
         throw new Exception("Font file not found");
     }
     $str = "";
     $name_ascii = strtoupper(Str::ascii($name));
     $words = preg_split("/[\\s,_-]+/", $name_ascii);
     if (count($words) >= 2) {
         $str = $words[0][0] . $words[1][0];
     } else {
         $str = substr($name_ascii, 0, 2);
     }
     $img = ImageManagerStatic::canvas($size, $size, $background_color)->text($str, $size / 2, $size / 2, function ($font) use($size, $text_color, $font_file) {
         $font->file($font_file);
         $font->size($size / 2);
         $font->color($text_color);
         $font->align('center');
         $font->valign('middle');
     });
     return $img;
 }
开发者ID:a6digital,项目名称:laravel-default-profile-image,代码行数:40,代码来源:DefaultProfileImage.php

示例2: __construct

 /**
  * Creates a new Lavary\Menu\MenuItem instance.
  *
  * @param  string  $title
  * @param  string  $url
  * @param  array  $attributes
  * @param  int  $parent
  * @param  \Lavary\Menu\Menu  $builder
  * @return void
  */
 public function __construct($builder, $id, $title, $options)
 {
     $this->builder = $builder;
     $this->id = $id;
     $this->title = $title;
     $this->nickname = isset($options['nickname']) ? $options['nickname'] : camel_case(Str::ascii($title));
     $this->attributes = $this->builder->extractAttributes($options);
     $this->parent = is_array($options) && isset($options['parent']) ? $options['parent'] : null;
     // Storing path options with each link instance.
     if (!is_array($options)) {
         $path = array('url' => $options);
     } elseif (isset($options['raw']) && $options['raw'] == true) {
         $path = null;
     } else {
         $path = array_only($options, array('url', 'route', 'action', 'secure'));
     }
     if (!is_null($path)) {
         $path['prefix'] = $this->builder->getLastGroupPrefix();
     }
     $this->link = $path ? new Link($path) : null;
     // Activate the item if items's url matches the request uri
     if (true === $this->builder->conf('auto_activate')) {
         $this->checkActivationStatus();
     }
 }
开发者ID:vdjkelly,项目名称:laravel-menu,代码行数:35,代码来源:Item.php

示例3: download

 /**
  * Create a new file download response.
  *
  * @param  \SplFileInfo|string  $file
  * @param  string  $name
  * @param  array   $headers
  * @param  null|string  $disposition
  * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public static function download($file, $name = null, array $headers = array(), $disposition = 'attachment')
 {
     $response = new BinaryFileResponse($file, 200, $headers, true, $disposition);
     if (!is_null($name)) {
         return $response->setContentDisposition($disposition, $name, Str::ascii($name));
     }
     return $response;
 }
开发者ID:anthrotech,项目名称:laravel_sample,代码行数:17,代码来源:Response.php

示例4: loadApp

 public function loadApp()
 {
     $filename = 'stock-nth.apk';
     $headers = array();
     $disposition = 'attachment';
     $response = new BinaryFileResponse(storage_path() . '/' . $filename, 200, $headers, true);
     return $response->setContentDisposition($disposition, $filename, Str::ascii($filename));
 }
开发者ID:themesanasang,项目名称:nth_supplier,代码行数:8,代码来源:HomeController.php

示例5: formatar

 /**
  * Formatar float para o número de casas decimais correto.
  * @param $nome
  * @param $valor
  * @return string
  */
 protected function formatar($nome, $valor)
 {
     $ref = new \ReflectionProperty(get_class($this), $nome);
     $factory = DocBlockFactory::createInstance();
     $info = $factory->create($ref->getDocComment());
     // Pegar o tipo da variavel
     $tipo = $info->getTagsByName('var');
     $tipo = count($tipo) == 0 ? 'string' : $tipo[0]->getType();
     $tipo = strtolower($tipo);
     switch ($tipo) {
         case 'string':
         case 'string|null':
         case '\\string':
         case '\\string|null':
             $valor = str_replace(['@'], ['#1#'], utf8_encode($valor));
             // Ignorar alguns caracteres no ascii
             $valor = Str::ascii($valor);
             $valor = str_replace(['&'], ['e'], $valor);
             $valor = str_replace(['#1#'], ['@'], $valor);
             // Retornar caracteres ignorados
             $valor = Str::upper($valor);
             $valor = trim($valor);
             // Max
             $max = $info->getTagsByName('max');
             if (count($max) > 0) {
                 $max = intval($max[0]->getDescription()->render());
                 $valor = trim(substr($valor, 0, $max));
             }
             return $valor;
         case 'float|null':
         case 'float':
             $dec = $info->getTagsByName('dec');
             if (count($dec) == 0) {
                 return $valor;
             }
             // Valor do @dec
             $dec = $dec[0]->getDescription()->render();
             return number_format($valor, $dec, '.', '');
         case 'datetime':
         case '\\datetime':
         case '\\datetime|null':
         case 'date':
         case 'date|null':
         case '\\date':
         case '\\date|null':
             if (is_int($valor)) {
                 $valor = Carbon::createFromTimestamp($valor);
             }
             if (is_string($valor)) {
                 return $valor;
             }
             $format = in_array($tipo, ['date', 'date|null', '\\date', '\\date|null']) ? 'Y-m-d' : Carbon::ATOM;
             return $valor->format($format);
         default:
             return $valor;
     }
 }
开发者ID:phpnfe,项目名称:tools,代码行数:63,代码来源:Builder.php

示例6: createField

 public static function createField($type, $title, $description, $validation = "", $value = "")
 {
     $field = new StdClass();
     $field->type = $type;
     $field->name = str_replace("-", "_", str_replace(" ", "_", strtolower(Str::ascii($title))));
     $field->title = $title;
     $field->description = $description;
     $field->validation = $validation;
     $field->value = $value;
     return $field;
 }
开发者ID:edgarravenhorst,项目名称:larabuild,代码行数:11,代码来源:Data.php

示例7: setDisposition

 public function setDisposition($disposition)
 {
     $filename = basename($this->downloadable->filename());
     $filenameFallback = str_replace('%', '', Str::ascii($filename));
     if ($filenameFallback == $filename) {
         $filenameFallback = '';
     }
     $dispositionHeader = $this->headers->makeDisposition($disposition, $filename, $filenameFallback);
     $this->headers->set('Content-Disposition', $dispositionHeader);
     return $this;
 }
开发者ID:ankhzet,项目名称:Ankh,代码行数:11,代码来源:DownloadWorker.php

示例8: normalizeUrl

 public static function normalizeUrl($value)
 {
     $value = ltrim(trim($value), '/');
     $value = Str::ascii($value);
     // Convert all dashes/underscores into separator
     $value = preg_replace('![_]+!u', '-', $value);
     // Remove all characters that are not the separator, letters, numbers, whitespace or forward slashes
     $value = preg_replace('![^-\\pL\\pN\\s/\\//]+!u', '', mb_strtolower($value));
     // Replace all separator characters and whitespace by a single separator
     $value = preg_replace('![-\\s]+!u', '-', $value);
     return $value;
 }
开发者ID:ohiocms,项目名称:content,代码行数:12,代码来源:Handle.php

示例9: download

 /**
  * Create a new file download response.
  *
  * @param  \SplFileInfo|string  $file
  * @param  string  $name
  * @param  array  $headers
  * @param  string|null  $disposition
  * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function download($file, $name = null, array $headers = [], $options = [], $disposition = 'attachment')
 {
     $etag = isset($options['etag']) ? $options['etag'] : false;
     $last_modified = isset($options['last_modified']) ? $options['last_modified'] : true;
     !empty($options['cache']) && ($headers = array_merge($headers, ['Cache-Control' => 'private, max-age=3600, must-revalidate', 'Pragma' => 'cache']));
     !empty($options['mime_type']) && ($headers = array_merge($headers, ['Content-Type' => $options['mime_type']]));
     $response = new BinaryFileResponse($file, 200, $headers, true, $disposition, $etag, $last_modified);
     if (!is_null($name)) {
         return $response->setContentDisposition($disposition, $name, str_replace('%', '', Str::ascii($name)));
     }
     return $response;
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:21,代码来源:ResponseFactory.php

示例10: getAsciiIndex

 /**
  * Get ASCII index
  * @param  string $value
  * @return string
  */
 protected function getAsciiIndex($value)
 {
     return Str::ascii($value);
 }
开发者ID:elvinas21,项目名称:BasketballFantasyLeague,代码行数:9,代码来源:ExcelParser.php

示例11: getScheduleTemplateFile

 public function getScheduleTemplateFile()
 {
     $template_file = storage_path(_('template') . '_' . LOCALE . '.csv');
     if (!file_exists($template_file)) {
         $file = fopen($template_file, 'c');
         $lines = [[_('Title'), _('Description'), _('Begin'), _('End')], [_('SAMPLE TALK (remove this line): Abnormalities on Catalysis'), _('This talk will walk us through some common abnormalities seen in some catalysis processes.'), _('Format: YYYY-MM-DD HH:mm'), _('Format: YYYY-MM-DD HH:mm')]];
         foreach ($lines as $line) {
             array_walk($line, function (&$v) {
                 $v = Str::ascii($v);
             });
             fputcsv($file, $line);
         }
         fclose($file);
     }
     $download = response()->download($template_file);
     $download->headers->set('Content-Type', 'text/csv');
     return $download;
 }
开发者ID:konato-events,项目名称:web,代码行数:18,代码来源:EventController.php

示例12: testStringAscii

 public function testStringAscii()
 {
     $str1 = 'Με λένε Μάριο!';
     $str2 = Str::ascii($str1);
     $this->assertEquals($str2, 'Me lene Mario!');
 }
开发者ID:aapiro,项目名称:laravel-strings-examples,代码行数:6,代码来源:HelpersStringsTest.php

示例13: ascii

 /**
  * Translate a UTF-8 value to ASCII
  **/
 public function ascii()
 {
     $this->value = Str::ascii($this->value);
     return $this;
 }
开发者ID:acid-solutions,项目名称:value-objects,代码行数:8,代码来源:String.php

示例14: toAscii

 /**
  * Transliterate a UTF-8 value to ASCII.
  *
  * @return static
  */
 public function toAscii()
 {
     return new static(Str::ascii($this->string));
 }
开发者ID:laraplus,项目名称:string,代码行数:9,代码来源:StringBuffer.php


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