本文整理汇总了PHP中Sanitize::saveInt方法的典型用法代码示例。如果您正苦于以下问题:PHP Sanitize::saveInt方法的具体用法?PHP Sanitize::saveInt怎么用?PHP Sanitize::saveInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sanitize
的用法示例。
在下文中一共展示了Sanitize::saveInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public static function save($value, $type, $standard = null)
{
$var = $standard;
if ($value !== null) {
if ($type == VAR_DB || $type == VAR_ARR_DB) {
$var = Sanitize::saveDb($value);
} elseif ($type == VAR_HTML || $type == VAR_ARR_HTML) {
$var = Sanitize::saveHTML($value);
} elseif ($type == VAR_INT || $type == VAR_ARR_INT) {
$var = Sanitize::saveInt($value);
} elseif ($type == VAR_ALNUM || $type == VAR_ARR_ALNUM) {
$var = Sanitize::saveAlNum($value, true);
} elseif ($type == VAR_URI || $type == VAR_ARR_URI) {
$var = Sanitize::saveAlNum($value, false);
} else {
$var = Sanitize::removeNullByte($value);
}
} else {
if ($standard === null) {
if ($type == VAR_DB || $type == VAR_ALNUM || $type == VAR_HTML || $type == VAR_URI) {
$var = '';
} elseif ($type == VAR_INT) {
$var = 0;
} elseif ($type == VAR_ARR_INT || $type == VAR_ARR_DB || $type == VAR_ARR_ALNUM || $type == VAR_ARR_NONE || $type == VAR_ARR_HTML || $type == VAR_ARR_URI) {
$var = array();
} else {
$var = null;
}
}
}
return $var;
}
示例2: set
/**
* Updates the value for the configuration key specified as parameter.
*
* If the third parameter is null (it is the default value) the script tries to get
* the value by name (without group!) from the input data (query string). If no data is found
* the default value from Variables::get() for the specified type will be used.
*
* This function throws a notice if the key is not found.
*
* The data won't be saved by this function! You have to call Config::save() for this!
*
* @see Variables::get()
* @see Config::save()
* @param string Config key in the format Group.Key
* @param int Type of variable (one of the standard types that are accepted by Request::get().
* @param mixed Value to change to specified config key.
**/
public static function set($key, $type = VAR_NONE, $value = null)
{
if (self::$data == null) {
self::baseConfig();
}
list($sgroup, $name) = explode('.', $key, 2);
if ($value == null) {
$value = Request::get($name, $type);
}
if (isset(self::$data[$key]) == true) {
self::$data[$key] = $value;
if ($type == VAR_INT || $type == VAR_ARR_INT) {
$value = Sanitize::saveInt($value);
}
self::$changes[$key] = array('key' => $key, 'value' => $value, 'type' => $type);
} else {
Core::throwError("Config::set() - Specified key does not exist.");
}
}