uintrule.class.php

来自「一个用PHP编写的」· PHP 代码 · 共 45 行

PHP
45
字号
<?php    lt_include(PLOG_CLASS_PATH."class/data/validator/rules/regexprule.class.php");    define( "UINT_RULE_REG_EXP", "^([0-9]+)$");    define( "ERROR_RULE_UINT_FORMAT_WRONG", "error_rule_uint_format_wrong");    /**     * \ingroup Validator_Rules     *     * Validates that the given value is an unsigned integer or not. If unsuccessful, the error     * ERROR_RULE_UINT_FORMAT_WRONG will be set.     */    class UIntRule extends RegExpRule    {        /**         * Initialize the rule         */        function UIntRule()        {            $this->RegExpRule(UINT_RULE_REG_EXP, false);        }        /**         * Checks whether the given value is an unsigned integer         *         * @return True if successful or false otherwise. If unsuccessful, the error         * ERROR_RULE_UINT_FORMAT_WRONG will be set.         */        function validate($value)        {            if (parent::validate($value))            {                $this->_setError(false);                return true;            }            else            {                $this->_setError(ERROR_RULE_UINT_FORMAT_WRONG);                return false;            }        }    }?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?