array是什么 意思"/> array是什么 意思">
Home > Backend Development > PHP Tutorial > "options"=>array是什么 意思

"options"=>array是什么 意思

WBOY
Release: 2016-06-23 14:01:15
Original
1377 people have browsed it

代码如下

<?php$var=300;$int_options = array("options"=>array ( "min_range"=>0, "max_range"=>256 ));if(!filter_var($var, FILTER_VALIDATE_INT, $int_options)) { echo("Integer is not valid"); }else { echo("Integer is valid"); }?>
Copy after login


回复讨论(解决方案)

$int_options = array(	"options"=>array	(		"min_range"=>0,		"max_range"=>256		)	);
Copy after login

php数组的定义
=> 是数组成员访问符号 键名为options,值为array("min_range"=>0,"max_range"=>256) ...

filter_var 是一个过滤器函数,由第二个参数指定过滤器类型,第三个参数指定过滤器所需参数
当有多个参数时,就要用二维数组表示了

filter_var($var, FILTER_VALIDATE_INT, $int_options)
FILTER_VALIDATE_INT 表示是一个整数范围过滤器
既然是范围,自然要给出下限(min_range)和上限(max_range)了

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template