PHP:preg_match函数不工作?
我有文件类型PHP:preg_match函数不工作?,php,Php,我有文件类型 $file_type = image/png if (!preg_match("/jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF/", $file_type)) { die('Apologies, file type error'); } 如果文件类型在给定的模式中不匹配,它将给出如上所示的模具。现在,即使模式中包含文件类型,也没有匹配 按钮行是,如果文件类型不正确,我需要死亡,否则继续。对我来说很好: <?php $file_type
$file_type = image/png
if (!preg_match("/jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF/", $file_type)) {
die('Apologies, file type error');
}
如果文件类型在给定的模式中不匹配,它将给出如上所示的模具。现在,即使模式中包含文件类型,也没有匹配
按钮行是,如果文件类型不正确,我需要死亡,否则继续。对我来说很好:
<?php
$file_type = "image/png";
if (!preg_match("#image/(?:png|jpg|webp|gif)#io", $file_type)) {
die('Apologies, file type error');
}
//if match file_type continue,