Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么不是';我的preg_match不区分大小写吗?_Php_Regex_Preg Match - Fatal编程技术网

Php 为什么不是';我的preg_match不区分大小写吗?

Php 为什么不是';我的preg_match不区分大小写吗?,php,regex,preg-match,Php,Regex,Preg Match,我的表单允许人们上传用于3d打印的文件,但我想将可能的文件限制为.obj或.stl } elseif (!preg_match("/^.*\.(stl|obj)$/i",$model['name'])) { //reject because it's not the correct extension. 当扩展名为小写(.stl)时,表单可以正常工作,但当扩展名为大写(.stl)时,表单会拒绝它这是一个愚蠢的人类把戏。这两种方式都不起作用。Barmar的评论帮助我查看并发现我的变量名有误。发生

我的表单允许人们上传用于3d打印的文件,但我想将可能的文件限制为.obj或.stl

} elseif (!preg_match("/^.*\.(stl|obj)$/i",$model['name'])) {
//reject because it's not the correct extension.

当扩展名为小写(.stl)时,表单可以正常工作,但当扩展名为大写(.stl)时,表单会拒绝它

这是一个愚蠢的人类把戏。这两种方式都不起作用。Barmar的评论帮助我查看并发现我的变量名有误。

发生这种情况时,请显示
var\u dump($mode['name'))
。这对我很有用。一定有别的东西拒绝上传。Barmar你的评论告诉我我做错了什么。我忘了在代码中的这一点上,我没有将东西移动到$model数组中。