本文整理汇总了PHP中filter_var_array函数的典型用法代码示例。如果您正苦于以下问题:PHP filter_var_array函数的具体用法?PHP filter_var_array怎么用?PHP filter_var_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_var_array函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: find
public function find()
{
$options = ['page' => FILTER_SANITIZE_NUMBER_INT, 'limit' => FILTER_SANITIZE_NUMBER_INT, 'type' => FILTER_SANITIZE_NUMBER_INT];
$values = filter_input_array(INPUT_GET, $options);
if (is_array($values)) {
$options['page'] = FILTER_VALIDATE_INT;
$options['limit'] = FILTER_VALIDATE_INT;
$options['type'] = FILTER_VALIDATE_INT;
$values = filter_var_array($values, $options);
}
if (empty($values) || $values['type'] === false) {
$this->render404();
return;
}
if ($values['page'] === false) {
$values['page'] = 1;
}
if ($values['limit'] === false) {
$values['limit'] = 10;
}
$news = $this->models->newsModel->paginateByType($values['type'], $values['page'], $values['limit']);
$count = ceil($this->models->newsModel->count($values['type']) / (double) $values['limit']);
if (count($news)) {
$this->render('find', ['news' => $news, 'count' => $count, 'page' => $values['page']]);
} else {
$this->render404();
}
}
开发者ID:senioroman4uk,项目名称:Simple-PHP-MVC,代码行数:28,代码来源:NewsController.php
示例2: sanitize
/**
* @param array $data исходные данные.
* @param array $rules правила валидации.
* @param array $errors ошибки, возникшие в ходе проверок.
* @return array возвращает очищенные и отвалидированные данные согласано указанным правилам.
* @link http://php.net/manual/ru/function.filter-var-array.php
*/
function sanitize(array $data, array $rules, &$errors = null)
{
$errors = is_array($errors) ? $errors : [];
foreach ($rules as $key => $rule) {
$rule['flags'] = isset($rule['flags']) ? $rule['flags'] | FILTER_NULL_ON_FAILURE : FILTER_NULL_ON_FAILURE;
$rule['required'] = isset($rule['required']) ? (bool) $rule['required'] : false;
$rule['message'] = isset($rule['message']) ? $rule['message'] : '';
$rules[$key] = $rule;
}
$data = array_map('trim', $data);
$filteredData = filter_var_array($data, $rules);
foreach ($filteredData as $attribute => $value) {
$rule = $rules[$attribute];
if (is_null($value)) {
if ($data[$attribute] || $data[$attribute] === '' && $rule['required']) {
sanitizeAddError($attribute, $rule['message'] ?: 'Не корректное значение в поле "{attribute}".', $errors);
}
}
if (is_string($value)) {
$value = trim($value);
$filteredData[$attribute] = $value;
if (!$value && $rule['required']) {
sanitizeAddError($attribute, $rule['message'] ?: 'Не заполнено обязательное поле "{attribute}".', $errors);
}
}
}
return $filteredData;
}
开发者ID:kyzima-spb,项目名称:simple-blog,代码行数:35,代码来源:sanitize.php
示例3: decode
public function decode($input)
{
$arr = explode(' ', $input);
$decodedInput = $output = array();
for ($i = 0; $i < count($arr); $i++) {
$nextElement = $i+1;
$key = substr($arr[$i], 1);
if ($this->parameterExistsInSchema($key)) {
if ($this->parameterHasValue($arr, $nextElement)) {
if ($this->parameterIsArray($key)) {
$value = explode(',', $arr[$nextElement]);
} else {
$value = $arr[$nextElement];
}
$i++;
} else {
$value = true;
}
} else {
throw new Exception("Parameter {$key} not defined");
}
$decodedInput[$key] = $value;
}
return filter_var_array($decodedInput, $this->schema);
}
开发者ID:rchavarria,项目名称:Septiembre-KataArgs,代码行数:28,代码来源:Args.php
示例4: sanitize
public static function sanitize(array $data, array $rules, $errors)
{
$errors = is_array($errors) ? $errors : [];
foreach ($rules as $key => $rule) {
$rule['flags'] = isset($rule['flags']) ? $rule['flags'] | FILTER_NULL_ON_FAILURE : FILTER_NULL_ON_FAILURE;
$rule['required'] = isset($rule['required']) ? (bool) $rule['required'] : false;
$rule['message'] = isset($rule['message']) ? $rule['message'] : '';
$rules[$key] = $rule;
}
$data = filter_var_array($data, $rules);
foreach ($data as $attribute => $value) {
$rule = $rules[$attribute];
if (is_null($value)) {
self::addError($attribute, $rule['message'] ?: 'Не корректное значение в поле "{attribute}".', $errors);
}
if (is_string($value)) {
if (!$value && $rule['required']) {
self::addError($attribute, $rule['message'] ?: 'Не заполнено обязательное поле "{attribute}".', $errors);
}
}
}
if (array_key_exists('password', $data) and array_key_exists('password_repeat', $data)) {
if ($data['password'] != $data['password_repeat']) {
self::$errors['password_repeat'] = 'Пароли не совпадают "password_repeat".';
}
}
return $data;
}
开发者ID:Vlladislav,项目名称:testing-knowledge,代码行数:28,代码来源:Validation.php
示例5: __construct
public function __construct()
{
parent::sessionStart();
$filterArgs = array('tm_key' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH), 'downloadToken' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH), 'source' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH), 'target' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH));
$__postInput = filter_var_array($_REQUEST, $filterArgs);
//NOTE: This is for debug purpose only,
//NOTE: Global $_POST Overriding from CLI Test scripts
//$__postInput = filter_var_array( $_POST, $filterArgs );
$this->tm_key = $__postInput['tm_key'];
$this->source = $__postInput['source'];
$this->target = $__postInput['target'];
$this->downloadToken = $__postInput['downloadToken'];
parent::disableSessions();
$userIsLogged = isset($_SESSION['cid']) && !empty($_SESSION['cid']);
if (!$userIsLogged) {
$output = "<pre>\n";
$output .= " - REQUEST URI: " . print_r(@$_SERVER['REQUEST_URI'], true) . "\n";
$output .= " - REQUEST Message: " . print_r($_REQUEST, true) . "\n";
$output .= "\n\t";
$output .= "Aborting...\n";
$output .= "</pre>";
Log::$fileName = 'php_errors.txt';
Log::doLog($output);
Utils::sendErrMailReport($output, "Download TMX Error: user Not Logged");
$this->unlockToken();
exit;
}
$this->uid = isset($_SESSION['uid']) && !empty($_SESSION['uid']) ? $_SESSION['uid'] : null;
$this->userMail = isset($_SESSION['cid']) && !empty($_SESSION['cid']) ? $_SESSION['cid'] : null;
$this->tmxHandler = new TMSService();
$this->tmxHandler->setTmKey($this->tm_key);
}
开发者ID:indynagpal,项目名称:MateCat,代码行数:32,代码来源:downloadTMXController.php
示例6: route
/**
* @return string|false
* @throws \RuntimeException
*/
protected function route()
{
$path = $this->getPathInfo();
if (empty($path)) {
$controllerName = 'index';
$actionName = 'index';
$args = array();
} else {
$segments = explode('/', $path);
$controllerName = $segments[0];
$actionName = isset($segments[1]) ? $segments[1] : 'index';
$args = filter_var_array(array_slice($segments, 2), FILTER_SANITIZE_STRING);
}
$class = '\\Readr\\Controller\\' . ucfirst($controllerName) . 'Controller';
if (!class_exists($class)) {
throw new \Exception("Page not found", 404);
}
$controller = new $class($this->getServiceManager());
$method = $actionName . 'Action';
if (!method_exists($controller, $method)) {
throw new \Exception("Page not found", 404);
}
$response = call_user_func_array(array($controller, $method), $args);
if (is_string($response)) {
return $response;
} elseif (is_array($response) || is_null($response)) {
$template = 'readr/views/' . strtolower($controllerName) . '/' . strtolower($actionName) . '.phtml';
$view = new View($template, $response);
$layout = new View('readr/views/layout.phtml', array('title' => 'Readr', 'content' => $view->render()));
return $layout->render();
}
return false;
}
开发者ID:slowmotion,项目名称:Readr,代码行数:37,代码来源:App.php
示例7: sanitize
function sanitize(array $data, array $rules, array &$errors = null)
{
$errors = is_array($errors) ? $errors : [];
//если приходит не массив, то превратить в массив
//1. этап - подготовка правил валидации / фильтрации
foreach ($rules as $attribute => $rule) {
$rule['flags'] = isset($rule['flags']) ? $rule['flags'] | FILTER_NULL_ON_FAILURE : FILTER_NULL_ON_FAILURE;
$rule['required'] = isset($rule['required']) ? (bool) $rule['required'] : false;
$rule['message'] = isset($rule['message']) ? $rule['message'] : '';
$rules[$attribute] = $rule;
}
//var_dump($rules);
//2. этап - непосредственно валидации / фильтрации
$data = array_map('trim', $data);
$filterData = filter_var_array($data, $rules);
foreach ($filterData as $attribute => $value) {
$rule = $rules[$attribute];
if (is_null($value)) {
if ($data[$attribute] || $data[$attribute] === '' && $rule['required']) {
sanitizeAddError($attribute, $rule['message'] ?: 'Некорректное значение в поле {attribute}', $errors);
}
}
if (is_string($value)) {
$value = trim($value);
//обрезаем пробелы,если есть лишние
$filterData[$attribute] = $value;
if (!$value && $rule['required']) {
sanitizeAddError($attribute, $rule['message'] ?: 'Не заполнено обязательное поле {attribute}', $errors);
}
}
}
return $filterData;
}
开发者ID:itmo-it-group-305,项目名称:rodion-kovalev.blog,代码行数:33,代码来源:sanitize.php
示例8: filter_array
public function filter_array($data = NULL, $filter = NULL, $options = NULL)
{
if (isset($filter)) {
$this->filter = $filter;
}
return filter_var_array($data, $this->filter);
}
开发者ID:andrew-ayers,项目名称:php,代码行数:7,代码来源:filters.php
示例9: validate_params
function validate_params($method, $params, $validators, $sanitizers)
{
if ($method == 'GET') {
$grab = $_GET;
} else {
if ($method == 'POST') {
$grab = $_POST;
}
}
$result = array();
$filters = array();
for ($i = 0; $i < count($validators); $i++) {
if (isset($grab[$params[$i]])) {
$filters[$params[$i]] = $validators[$i];
} else {
return false;
}
}
$result = filter_var_array($grab, $filters);
$filters = array();
for ($i = 0; $i < count($sanitizers); $i++) {
if ($result[$params[$i]] !== false) {
$filters[$params[$i]] = $sanitizers[$i];
} else {
return false;
}
}
return filter_var_array($result, $filters);
}
开发者ID:dulinriley,项目名称:classmatches,代码行数:29,代码来源:common.php
示例10: addRepublica
/**
* @param (float|int|string)[] $republica
* @param int $who_posted
*/
public static function addRepublica(array $republica, $whoPosted, Database &$database)
{
$filterFloat = array('filter' => FILTER_SANITIZE_NUMBER_FLOAT, 'flags' => FILTER_FLAG_ALLOW_FRACTION);
$options = array('name' => FILTER_SANITIZE_STRING, 'latitude' => $filterFloat, 'longitude' => $filterFloat, 'phone' => FILTER_SANITIZE_STRING, 'email' => FILTER_SANITIZE_EMAIL, 'address' => FILTER_SANITIZE_STRING, 'more' => FILTER_SANITIZE_STRING);
$republica = filter_var_array($republica, $options);
$whoPosted = filter_var($whoPosted, FILTER_SANITIZE_NUMBER_INT);
$valid = (bool) filter_var($republica['email'], FILTER_VALIDATE_EMAIL);
$valid &= (bool) filter_var($whoPosted, FILTER_VALIDATE_INT);
$success = false;
if ($valid) {
$query = $database->prepare('
INSERT INTO republicas (
name, latitude, longitude, phone, email,
address, who_posted, more
) VALUES (
:name, :latitude, :longitude, :phone, :email,
:address, :who_posted, :more
)
');
do {
$query->bindParam(':' . key($republica), current($republica));
} while (next($republica) !== false);
$query->bindParam(':who_posted', $whoPosted, Database::PARAM_INT);
$success = $query->execute();
}
return $success;
}
开发者ID:engenhariaSI,项目名称:pingpONG,代码行数:31,代码来源:Republicas.php
示例11: process
static function process($filters, $source = INPUT_POST, $required_by_default = false, $strict = true)
{
# parse filters
list($filters, $required, $defaults) = self::parse_filters($filters, $required_by_default);
# apply
$d = is_array($source) ? filter_var_array($source, $filters) : filter_input_array($source, $filters);
if ($d === null) {
$d = array_fill_keys(array_keys($filters), null);
}
# check required and set undefined to null (rather than false)
foreach ($filters as $field => $filter) {
$isa = is_array($filter);
if ($d[$field] === null || $d[$field] === false && ($isa ? $filter['filter'] : $filter) !== FILTER_VALIDATE_BOOLEAN) {
if ($strict && isset($required[$field])) {
throw new UnexpectedValueException($field . ' is required');
} elseif (isset($defaults[$field])) {
if ($filter !== FILTER_DEFAULT) {
if ($isa) {
$d[$field] = filter_var($defaults[$field], $filter['filter'], isset($filter['options']) ? $filter['options'] : null);
} else {
$d[$field] = filter_var($defaults[$field], $filter);
}
} else {
$d[$field] = $defaults[$field];
}
} else {
$d[$field] = null;
}
}
}
return $d;
}
开发者ID:rsms,项目名称:gitblog,代码行数:32,代码来源:gb_input.php
示例12: sanitizeInputArray
/**
* @param $data
* @return mixed
*/
public function sanitizeInputArray($data)
{
$filter = FILTER_SANITIZE_STRING;
$flags = [FILTER_FLAG_STRIP_HIGH, FILTER_FLAG_STRIP_LOW];
$args = $this->recursiveArgs($data, $filter, $flags);
return filter_var_array($data, $args);
}
开发者ID:marsoltys,项目名称:qasapi,代码行数:11,代码来源:Utils.php
示例13: find
public function find()
{
$options = ['page' => FILTER_SANITIZE_NUMBER_INT, 'limit' => FILTER_SANITIZE_NUMBER_INT];
$values = filter_input_array(INPUT_GET, $options);
if (is_array($values)) {
$options['page'] = FILTER_VALIDATE_INT;
$options['limit'] = FILTER_VALIDATE_INT;
$values = filter_var_array($values, $options);
}
if (empty($values)) {
$values = ['page' => false, 'limit' => false];
}
if ($values['page'] === false) {
$values['page'] = 1;
}
if ($values['limit'] === false) {
$values['limit'] = 10;
}
$messages = $this->models->messageModel->paginate($values['page'], $values['limit'], ['date DESC']);
$count = $this->models->messageModel->count();
if (count($messages)) {
$this->render('find', ['messages' => $messages, 'count' => $count, 'page' => $values['page']]);
} else {
$this->render404();
}
}
开发者ID:senioroman4uk,项目名称:Simple-PHP-MVC,代码行数:26,代码来源:MessageController.php
示例14: accountNightmode
function accountNightmode()
{
require "functions/common.php";
require "functions/import_info.php";
if (isset($_GET['accountNightmode'])) {
if (empty($_POST['nightmode_state'])) {
die("You missed a field");
header("Location: " . $_SERVER['SCRIPT_NAME']);
}
$_POST = filter_var_array($_POST, FILTER_SANITIZE_STRING);
$email = $_SESSION['user']['email'];
$first_name = $row_info['first_name'];
$last_name = $row_info['last_name'];
$birthday = $row_info['birthday'];
$nightmode = $_POST['nightmode_state'];
$user_id = $row_info['id'];
$query = "\n\t\t\tREPLACE INTO info (\n\t\t\t\tid,\n\t\t\t\temail,\n\t\t\t\tfirst_name,\n\t\t\t\tlast_name,\n\t\t\t\tbirthday,\n\t\t\t\tnightmode\n\t\t\t) VALUES (\n\t\t\t\t'{$user_id}',\n\t\t\t\t'{$email}',\n\t\t\t\t'{$first_name}',\n\t\t\t\t'{$last_name}',\n\t\t\t\t'{$birthday}',\n\t\t\t\t'{$nightmode}'\n\t\t\t);";
try {
$stmt = $db->prepare($query);
$stmt->execute();
header("Location: " . $_SERVER['SCRIPT_NAME']);
} catch (PDOException $ex) {
die("Failed to run query: " . $ex->getMessage());
header("Location: " . $_SERVER['SCRIPT_NAME']);
}
}
}
开发者ID:malsf21,项目名称:robotics-club-website,代码行数:27,代码来源:user_account.php
示例15: startInit
/** startInit() initiates the environment
* @return void
*/
public static function startInit()
{
@set_time_limit(0);
@error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);
@ini_set('session.save_handler', 'mm');
@ini_set('session.cookie_httponly', true);
@ob_start('sanitize_output');
@session_start();
@session_cache_limiter('no-cache');
@session_set_cookie_params(0, null, null, true, true);
@set_magic_quotes_runtime(0);
self::verCheck();
self::extCheck();
foreach ($_REQUEST as $key => $val) {
$_REQUEST[$key] = is_array($val) ? filter_var_array($val, FILTER_SANITIZE_STRING) : filter_var($val, FILTER_SANITIZE_STRING);
}
foreach ($_GET as $key => $val) {
$_GET[$key] = is_array($val) ? filter_var_array($val, FILTER_SANITIZE_STRING) : filter_var($val, FILTER_SANITIZE_STRING);
}
foreach ($_POST as $key => $val) {
$_POST[$key] = is_array($val) ? filter_var_array($val, FILTER_SANITIZE_STRING) : filter_var($val, FILTER_SANITIZE_STRING);
}
foreach (array('node', 'sub', 'printertype', 'id', 'sub', 'crit', 'sort', 'confirm', 'tab') as $x) {
global ${$x};
${$x} = isset($_REQUEST[$x]) ? filter_var($_REQUEST[$x], FILTER_SANITIZE_STRING) : '';
}
unset($x);
new System();
new Config();
}
开发者ID:bramverstraten,项目名称:fogproject,代码行数:33,代码来源:init.php
示例16: _failRules
protected function _failRules($input)
{
$output = array();
foreach ($input as $key => $value) {
if (!empty($value)) {
$output[$key] = $value;
}
}
foreach ($this->_rules as $index => $stack) {
$tmp_output = filter_var_array($output, array_intersect_key($stack, $output));
foreach ($tmp_output as $key => $value) {
if (empty($this->_rules[$index][$key])) {
continue;
}
if ($this->_validated[$key]) {
continue;
// skip values that allready failed validation
}
if (FILTER_VALIDATE_BOOLEAN == $this->_rules[$index][$key]['filter']) {
$tmp_output[$key] = (bool) $value;
} elseif (false === $value) {
$this->_result->addError($key, $this->_messages[$index][$key]);
$this->_validated[$key] = true;
// set 'break validation chain' flag
}
}
$output = array_merge($output, $tmp_output);
}
$output = array_merge($input, $output);
$ok = $this->_result->ok();
if ($ok) {
$this->_result->import($output);
}
return !$ok;
}
开发者ID:nakonechny,项目名称:naf,代码行数:35,代码来源:Validator.php
示例17: index_add
public function index_add()
{
$t_recipe = D('recipe');
$id = filter_var($this->_get('id'), FILTER_VALIDATE_INT);
$type = filter_var($this->_get('type'), FILTER_SANITIZE_STRING);
$where = array('token' => session('token'), 'id' => $id, 'type' => $type);
$recipe = $t_recipe->where($where)->find();
if (IS_POST) {
$filters = array('keyword' => array('filter' => FILTER_SANITIZE_STRIPPED, 'flags' => FILTER_SANITIZE_STRING, 'options' => FILTER_SANITIZE_ENCODED), 'title' => array('filter' => FILTER_SANITIZE_STRIPPED, 'flags' => FILTER_SANITIZE_STRING, 'options' => FILTER_SANITIZE_ENCODED));
$_POST['begintime'] = strtotime(filter_var($this->_post('begintime'), FILTER_SANITIZE_STRING));
$_POST['endtime'] = strtotime(filter_var($this->_post('endtime'), FILTER_SANITIZE_STRING));
$_POST['type'] = filter_var($this->_post('type'), FILTER_SANITIZE_STRING);
if ($_POST['begintime'] > $_POST['endtime']) {
exit($this->error('您好,开始时间不能大于结束时间.', U("Recipe/index", array('token' => session('token'), 'type' => $type))));
}
$check = filter_var_array($_POST, $filters);
if (!$check) {
exit($this->error('您好,包含敏感字符,或者是不允许字串!', U("Recipe/index", array('token' => session('token'), 'type' => $type))));
}
$_POST['monday'] = serialize($_REQUEST['monday']);
$_POST['tuesday'] = serialize($_REQUEST['tuesday']);
$_POST['wednesday'] = serialize($_REQUEST['wednesday']);
$_POST['thursday'] = serialize($_REQUEST['thursday']);
$_POST['friday'] = serialize($_REQUEST['friday']);
$_POST['saturday'] = serialize($_REQUEST['saturday']);
$_POST['sunday'] = serialize($_REQUEST['sunday']);
$_POST['token'] = session('token');
if (!$t_recipe->create()) {
exit($this->error($t_recipe->getError()));
} else {
$id = filter_var($this->_post('id'), FILTER_VALIDATE_INT);
$status = filter_var($this->_post('status'), FILTER_SANITIZE_STRING);
if ('edit' == $status && $id != '') {
$o = $t_recipe->where(array('id' => $id, 'token' => session('token')))->save($_POST);
if ($o) {
$data2['keyword'] = filter_var($this->_post('keyword'), FILTER_SANITIZE_STRING);
M('Keyword')->where(array('pid' => $id, 'token' => session('token'), 'module' => 'Recipe'))->data($data2)->save();
exit($this->success('修改成功', U("Recipe/index", array('token' => session('token'), 'type' => $_POST['type']))));
} else {
exit($this->error('修改失败', U("Recipe/index", array('token' => session('token'), 'type' => $_POST['type']))));
}
} else {
if ($id = $t_recipe->data($_POST)->add()) {
$data1['pid'] = $id;
$data1['module'] = 'Recipe';
$data1['token'] = session('token');
$data1['keyword'] = filter_var($this->_post('keyword'), FILTER_SANITIZE_STRING);
M('Keyword')->add($data1);
$this->success('添加成功', U("Recipe/index", array('token' => session('token'), 'type' => $_POST['type'])));
exit;
} else {
exit($this->error('务器繁忙,添加失败,请稍候再试', U("Recipe/index", array('token' => session('token'), 'type' => $_POST['type']))));
}
}
}
}
$this->assign('recipe', $recipe);
$this->display();
}
开发者ID:ww102111,项目名称:weixin,代码行数:59,代码来源:RecipeAction.class.php
示例18: getArray
/**
* {@inheritdoc}
*/
public function getArray($definition = null, $addEmpty = true)
{
$values = array();
foreach ($this->loadArray as $key) {
$values[$key] = $this->getFunctionValue($key);
}
return filter_var_array($values, $definition, $addEmpty);
}
开发者ID:jeremysells,项目名称:PhpWrapers,代码行数:11,代码来源:AbstractFilterFunction.php
示例19: validateNote
public function validateNote($note = array(), $action = 'create')
{
$errors = array();
$note = filter_var_array($note, array('id' => FILTER_SANITIZE_NUMBER_INT, 'body' => FILTER_SANITIZE_STRING, 'contact_id' => FILTER_SANITIZE_NUMBER_INT), false);
if (isset($note['body']) && empty($note['body'])) {
$errors[] = array('field' => 'body', 'message' => 'Note body cannot be empty');
}
return $errors;
}
开发者ID:andrejuseu,项目名称:REST,代码行数:9,代码来源:Application.php
示例20: get
/**
* @param null|string $key
* @param null|mixed $default
* @return mixed|null
*/
public function get($key = null, $default = null)
{
if ($key === null) {
return filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
} elseif (isset($_GET[$key])) {
return is_array($_GET[$key]) ? filter_var_array($_GET[$key], FILTER_SANITIZE_STRING) : filter_var($_GET[$key], FILTER_SANITIZE_STRING);
}
return $default;
}
开发者ID:jamieynonan,项目名称:core-plugin-wp,代码行数:14,代码来源:Request.php
注:本文中的filter_var_array函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论