Sanitize::html PHP Метод

html() публичный статический Метод

public static html ( $string, $encode = true )
    public static function html($string, $encode = true)
    {
        $filter = $encode ? FILTER_SANITIZE_SPECIAL_CHARS : FILTER_SANITIZE_STRING;
        return filter_var($string, $filter, FILTER_FLAG_ENCODE_AMP);
    }

Usage Example

Пример #1
0
 public function show()
 {
     if (!isset($this->params['type'])) {
         $this->error(ECode::$MAIL_NOBOX);
     }
     if (!isset($this->params['num'])) {
         $this->error(ECode::$MAIL_NOMAIL);
     }
     $type = $this->params['type'];
     $num = $this->params['num'];
     try {
         $box = new MailBox(User::getInstance(), $type);
         $mail = Mail::getInstance($num, $box);
     } catch (Exception $e) {
         $this->error(ECode::$MAIL_NOMAIL);
     }
     $this->notice = $box->desc . "-阅读邮件";
     $mail->setRead();
     $content = $mail->getHtml();
     preg_match("|来  源:[\\s]*([0-9a-zA-Z.:*]+)|", $content, $f);
     $f = empty($f) ? "" : "<br />FROM {$f[1]}";
     $s = ($pos = strpos($content, "<br/><br/>")) === false ? 0 : $pos + 10;
     $e = ($pos = strpos($content, "<br/>--<br/>")) === false ? strlen($content) : $pos + 7;
     $content = substr($content, $s, $e - $s) . $f;
     if (Configure::read("ubb.parse")) {
         $content = XUBB::parse($content);
     }
     App::import("Sanitize");
     $this->set("type", $type);
     $this->set("num", $mail->num);
     $this->set("title", Sanitize::html($mail->TITLE));
     $this->set("sender", $mail->OWNER);
     $this->set("time", date("Y-m-d H:i:s", $mail->POSTTIME));
     $this->set("content", $content);
 }
All Usage Examples Of Sanitize::html
Sanitize