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


PHP str::utf8方法代码示例

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


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

示例1: sanitize

 /** 
  * A set of sanitizer methods
  * 
  * @param  string  $string The string to sanitize
  * @param  string  $type The method
  * @param  string  $default The default value if the string will be empty afterwards
  * @return string  The sanitized string
  */
 static function sanitize($string, $type = 'str', $default = null)
 {
     $string = stripslashes((string) $string);
     $string = urldecode($string);
     $string = str::utf8($string);
     switch ($type) {
         case 'int':
             $string = (int) $string;
             break;
         case 'str':
             $string = (string) $string;
             break;
         case 'array':
             $string = (array) $string;
             break;
         case 'nohtml':
             $string = self::unhtml($string);
             break;
         case 'noxml':
             $string = self::unxml($string);
             break;
         case 'enum':
             $string = in_array($string, array('y', 'n')) ? $string : $default;
             $string = in_array($string, array('y', 'n')) ? $string : 'n';
             break;
         case 'checkbox':
             $string = $string == 'on' ? 'y' : 'n';
             break;
         case 'url':
             $string = v::url($string) ? $string : '';
             break;
         case 'email':
             $string = v::email($string) ? $string : '';
             break;
         case 'plain':
             $string = str::unxml($string);
             $string = str::unhtml($string);
             $string = str::trim($string);
             break;
         case 'lower':
             $string = str::lower($string);
             break;
         case 'upper':
             $string = str::upper($string);
             break;
         case 'words':
             $string = str::sanitize($string, 'plain');
             $string = preg_replace('/[^\\pL]/u', ' ', $string);
         case 'tags':
             $string = str::sanitize($string, 'plain');
             $string = preg_replace('/[^\\pL\\pN]/u', ' ', $string);
             $string = str::trim($string);
         case 'nobreaks':
             $string = str_replace('\\n', '', $string);
             $string = str_replace('\\r', '', $string);
             $string = str_replace('\\t', '', $string);
             break;
         case 'url':
             $string = self::urlify($string);
             break;
         case 'filename':
             $string = f::safe_name($string);
             break;
     }
     return trim($string);
 }
开发者ID:sdvig,项目名称:kirbycms,代码行数:74,代码来源:kirby.php

示例2: catch

            // reset the error
            $this->error = null;
            return true;
        } catch (Exception $e) {
            $this->error = $e;
            return false;
        }
    }
}
/**
 * Default mail driver
 */
email::$services['mail'] = function ($email) {
    $headers = array('From: ' . $email->from, 'Reply-To: ' . $email->replyTo, 'Return-Path: ' . $email->replyTo, 'Message-ID: <' . time() . '-' . $email->from . '>', 'X-Mailer: PHP v' . phpversion(), 'Content-Type: text/plain; charset=utf-8', 'Content-Transfer-Encoding: 8bit');
    ini_set('sendmail_from', $email->from);
    $send = mail($email->to, str::utf8($email->subject), str::utf8($email->body), implode(PHP_EOL, $headers));
    ini_restore('sendmail_from');
    if (!$send) {
        throw new Error('The email could not be sent');
    }
};
/**
 * Amazon mail driver
 */
email::$services['amazon'] = function ($email) {
    if (empty($email->options['key'])) {
        throw new Error('Missing Amazon API key');
    }
    if (empty($email->options['secret'])) {
        throw new Error('Missing Amazon API secret');
    }
开发者ID:biggtfish,项目名称:Clean-Blog-Kirby-Theme,代码行数:31,代码来源:email.php

示例3: testUtf8

 public function testUtf8()
 {
     $this->assertEquals($this->sample, str::utf8($this->sample));
 }
开发者ID:aoimedia,项目名称:kosmonautensofa,代码行数:4,代码来源:StrTest.php

示例4: sendWithMail

 private function sendWithMail()
 {
     $headers = array();
     $headers[] = 'From: ' . $this->options['from'];
     $headers[] = 'Reply-To: ' . $this->options['replyto'];
     $headers[] = 'Return-Path: ' . $this->options['replyto'];
     $headers[] = 'Message-ID: <' . time() . '-' . $this->options['from'] . '>';
     $headers[] = 'X-Mailer: PHP v' . phpversion();
     $headers[] = 'Content-Type: text/plain; charset=utf-8';
     $headers[] = 'Content-Transfer-Encoding: 8bit';
     ini_set('sendmail_from', $this->options['from']);
     $send = mail($this->options['to'], str::utf8($this->options['subject']), str::utf8($this->options['body']), implode("\r\n", $headers));
     ini_restore('sendmail_from');
     if (!$send) {
         return array('status' => 'error', 'msg' => l::get('email.error', 'The mail could not be sent!'));
     }
     return array('status' => 'success', 'msg' => l::get('email.success', 'The mail has been sent'));
 }
开发者ID:scheibome,项目名称:kirbycms-extensions,代码行数:18,代码来源:email.php


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