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


PHP str::encode方法代码示例

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


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

示例1: email

 /**
  * Generates an "a mailto" tag
  *
  * @param string $href The url for the a tag
  * @param mixed $text The optional text. If null, the url will be used as text
  * @param array $attr Additional attributes for the tag
  * @return string the generated html
  */
 public static function email($email, $text = null, $attr = array())
 {
     $email = str::encode($email, 3);
     $attr = array_merge(array('href' => 'mailto:' . $email), $attr);
     if (empty($text)) {
         $text = $email;
     }
     return static::tag('a', $text, $attr);
 }
开发者ID:robinandersen,项目名称:robin,代码行数:17,代码来源:html.php

示例2: captcha

 /**
  * Re-generates and returns the obfuscated captcha of the `calc` guard.
  * 
  * @return string
  */
 public function captcha()
 {
     $this->generateCaptcha();
     return str::encode(s::get($this->id . '-captcha-label'));
 }
开发者ID:peterbinks,项目名称:peterbinks.net,代码行数:10,代码来源:UniForm.php

示例3: uniform_captcha

/**
 * Generates a new calculate captcha result for a Uniform form
 *
 * @param UniForm $form The form to generate the captcha for
 * @return string A label like '4 plus 5'
 */
function uniform_captcha(UniForm $form)
{
    list($a, $b) = array(rand(0, 9), rand(0, 9));
    s::set($form->id() . '-captcha-result', $a + $b);
    return str::encode($a . ' ' . l::get('uniform-calc-plus') . ' ' . $b);
}
开发者ID:fetzi,项目名称:kirby-uniform,代码行数:12,代码来源:calc.php

示例4: email

 /**
  * Generates an "a mailto" tag
  *
  * @param string $email The url for the a tag
  * @param mixed $text The optional text. If null, the url will be used as text
  * @param array $attr Additional attributes for the tag
  * @return string the generated html
  */
 public static function email($email, $text = null, $attr = array())
 {
     if (empty($text)) {
         // show only the eMail address without additional parameters (if the 'text' argument is empty)
         $text = str::encode(a::first(str::split($email, '?')));
     }
     $email = str::encode($email);
     $attr = array_merge(array('href' => 'mailto:' . $email), $attr);
     return static::tag('a', $text, $attr);
 }
开发者ID:getkirby,项目名称:toolkit,代码行数:18,代码来源:html.php

示例5: function

<?php

/**
 * Allows to obfuscate E-Mail addresses. At least we try to make it a bit more
 * more difficult for bots to gather our mail addresses.
 *
 * @param  Field  $field  The calling Kirby Field instance.
 */
field::$methods['obfuscate'] = function ($field) {
    return str::encode($field->value());
};
/**
 * Removes all HTML tags from the field value before parsing the field as
 * markdown. Encodes all special characters of the resulting string as html
 * entities to allow only a predefined list of tags. This method should be used
 * to allow markdown in user generated contents.
 *
 * @see  http://shiflett.org/blog/2007/mar/allowing-html-and-preventing-xss
 *
 * @param  Field  $field  The calling Kirby Field instance.
 * @param  array  $tags   List of html tags to allow.
 *
 * @return Field
 */
field::$methods['safeMarkdown'] = function ($field, $tags = null) {
    // Sensible default for user generated contents
    if (!is_array($tags)) {
        $tags = array('a', 'p', 'em', 'strong', 'ul', 'ol', 'li', 'code', 'pre', 'blockquote');
    }
    // Ensure the string is utf-8 encoded to protect against XSS exploits using
    // different encodings.
开发者ID:buditanrim,项目名称:kirby-comments,代码行数:31,代码来源:methods.php


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