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


PHP v::max方法代碼示例

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


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

示例1: testMax

 public function testMax()
 {
     $this->assertTrue(v::max('superstring', 11));
     $this->assertFalse(v::max('superstring', 5));
     $this->assertTrue(v::max(6, 11));
     $this->assertFalse(v::max(6, 5));
     $this->assertTrue(v::max(range(0, 10), 11));
     $this->assertFalse(v::max(range(0, 10), 5));
 }
開發者ID:nsteiner,項目名稱:kdoc,代碼行數:9,代碼來源:VTest.php

示例2: validate

 public function validate()
 {
     if (!v::num($this->result())) {
         return false;
     }
     if ($this->min and !v::min($this->result(), $this->min)) {
         return false;
     }
     if ($this->max and !v::max($this->result(), $this->max)) {
         return false;
     }
     return true;
 }
開發者ID:muten84,項目名稱:luigibifulco.it,代碼行數:13,代碼來源:number.php

示例3: validate

 public function validate()
 {
     if ($this->validate and is_array($this->validate)) {
         return parent::validate();
     } else {
         if ($this->min and !v::min($this->result(), $this->min)) {
             return false;
         }
         if ($this->max and !v::max($this->result(), $this->max)) {
             return false;
         }
     }
     return true;
 }
開發者ID:madebypost,項目名稱:Gulp-Neat-KirbyCMS,代碼行數:14,代碼來源:text.php

示例4: call_user_func_array

        return call_user_func_array(static::$validators[$method], $arguments);
    }
}
/**
 * Default set of validators
 */
v::$validators = array('accepted' => function ($value) {
    return v::in($value, array(1, true, 'yes', 'true', '1', 'on'));
}, 'denied' => function ($value) {
    return v::in($value, array(0, false, 'no', 'false', '0', 'off'));
}, 'alpha' => function ($value) {
    return v::match($value, '/^([a-z])+$/i');
}, 'alphanum' => function ($value) {
    return v::match($value, '/^[a-z0-9]+$/i');
}, 'between' => function ($value, $min, $max) {
    return v::min($value, $min) && v::max($value, $max);
}, 'date' => function ($value) {
    $time = strtotime($value);
    if (!$time) {
        return false;
    }
    $year = date('Y', $time);
    $month = date('m', $time);
    $day = date('d', $time);
    return checkdate($month, $day, $year);
}, 'different' => function ($value, $other) {
    return $value !== $other;
}, 'email' => function ($value) {
    return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
}, 'filename' => function ($value) {
    return v::match($value, '/^[a-z0-9@._-]+$/i') && v::min($value, 2);
開發者ID:kristianhalte,項目名稱:super_organic,代碼行數:31,代碼來源:v.php

示例5: function

}, 'filename' => function ($value) {
    return v::match($value, '/^[a-z0-9@._-]+$/i') and v::min($value, 2);
}, 'in' => function ($value, $in) {
    return in_array($value, $in, true);
}, 'integer' => function ($value) {
    return filter_var($value, FILTER_VALIDATE_INT) !== false;
}, 'ip' => function ($value) {
    return filter_var($value, FILTER_VALIDATE_IP) !== false;
}, 'match' => function ($value, $preg) {
    return preg_match($preg, $value) == true;
}, 'max' => function ($value, $max) {
    return size($value) <= $max;
}, 'min' => function ($value, $min) {
    return size($value) >= $min;
}, 'maxWords' => function ($value, $max) {
    return v::max(explode(' ', $value), $max);
}, 'minWords' => function ($value, $min) {
    return v::min(explode(' ', $value), $min);
}, 'notIn' => function ($value, $notIn) {
    return !v::in($value, $notIn);
}, 'num' => function ($value) {
    return is_numeric($value);
}, 'required' => function ($key, $array) {
    return !empty($array[$key]);
}, 'same' => function ($value, $other) {
    return $value === $other;
}, 'size' => function ($value, $size) {
    return size($value) == $size;
}, 'url' => function ($value) {
    // In search for the perfect regular expression: https://mathiasbynens.be/demo/url-regex
    $regex = '_^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\x{00a1}-\\x{ffff}0-9]+-?)*[a-z\\x{00a1}-\\x{ffff}0-9]+)(?:\\.(?:[a-z\\x{00a1}-\\x{ffff}0-9]+-?)*[a-z\\x{00a1}-\\x{ffff}0-9]+)*(?:\\.(?:[a-z\\x{00a1}-\\x{ffff}]{2,})))(?::\\d{2,5})?(?:/[^\\s]*)?$_iu';
開發者ID:robinandersen,項目名稱:robin,代碼行數:31,代碼來源:v.php

示例6: Exception

            throw new Exception('The validator does not exist: ' . $method);
        }
        return call_user_func_array(static::$validators[$method], $arguments);
    }
}
/**
 * Default set of validators
 */
v::$validators = array('accepted' => function ($value) {
    return v::in($value, array(1, true, 'yes', 'true', '1', 'on'));
}, 'alpha' => function ($value) {
    return v::match($value, '/^([a-z])+$/i');
}, 'alphanum' => function ($value) {
    return v::match($value, '/^[a-z0-9]+$/i');
}, 'between' => function ($value, $min, $max) {
    return v::min($value, $min) and v::max($value, $max);
}, 'date' => function ($value) {
    $time = strtotime($value);
    if (!$time) {
        return false;
    }
    $year = date('Y', $time);
    $month = date('m', $time);
    $day = date('d', $time);
    return checkdate($month, $day, $year);
}, 'different' => function ($value, $other) {
    return $value !== $other;
}, 'email' => function ($value) {
    return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
}, 'filename' => function ($value) {
    return v::match($value, '/^[a-z0-9@._-]+$/i') and v::min($value, 2);
開發者ID:LucasFyl,項目名稱:korakia,代碼行數:31,代碼來源:v.php


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