當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Vars::limit方法代碼示例

本文整理匯總了PHP中Vars::limit方法的典型用法代碼示例。如果您正苦於以下問題:PHP Vars::limit方法的具體用法?PHP Vars::limit怎麽用?PHP Vars::limit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Vars的用法示例。


在下文中一共展示了Vars::limit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getGravatarUrl

 /**
  * Generates an Gravatar URL.
  *
  * Size of the image:
  * * The default size is 32px, and it can be anywhere between 1px up to 2048px.
  * * If requested any value above the allowed range, then the maximum is applied.
  * * If requested any value bellow the minimum, then the default is applied.
  *
  * Default image:
  * * It can be an URL to an image.
  * * Or one of built in options that Gravatar has. See Email::getGravatarBuiltInImages().
  * * If none is defined then a built in default is used. See Email::getGravatarBuiltInDefaultImage().
  *
  * @param string $email
  * @param int    $size
  * @param string $defaultImage
  * @return null|string
  * @link http://en.gravatar.com/site/implement/images/
  */
 public static function getGravatarUrl($email, $size = 32, $defaultImage = 'identicon')
 {
     if (empty($email) || self::_isValid($email) === false) {
         return null;
     }
     $hash = md5(strtolower(trim($email)));
     $parts = array('scheme' => 'http', 'host' => 'www.gravatar.com');
     if (Url::isHttps()) {
         $parts = array('scheme' => 'https', 'host' => 'secure.gravatar.com');
     }
     // Get size
     $size = Vars::limit(Filter::int($size), 32, 2048);
     // Prepare default images
     $defaultImage = trim($defaultImage);
     if (preg_match('/^(http|https)./', $defaultImage)) {
         $defaultImage = urldecode($defaultImage);
     } else {
         $defaultImage = strtolower($defaultImage);
         if (!Arr::in((string) $defaultImage, self::getGravatarBuiltInImages())) {
             $defaultImage = self::getGravatarBuiltInDefaultImage();
         }
     }
     // Build full url
     $parts['path'] = '/avatar/' . $hash . '/';
     $parts['query'] = array('s' => $size, 'd' => $defaultImage);
     $url = Url::create($parts);
     return $url;
 }
開發者ID:jbzoo,項目名稱:utils,代碼行數:47,代碼來源:Email.php

示例2: opacity

 /**
  * Check opacity value
  *
  * @param $opacity
  * @return int
  */
 public static function opacity($opacity)
 {
     if ($opacity <= 1) {
         $opacity *= 100;
     }
     $opacity = Filter::int($opacity);
     $opacity = Vars::limit($opacity, 0, 100);
     return $opacity;
 }
開發者ID:jbzoo,項目名稱:utils,代碼行數:15,代碼來源:Image.php


注:本文中的Vars::limit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。