我正在检查信用卡字段以确保它们每个都包含四位数字。
function creditcard ($creditCard1,$creditCard2,$creditCard3,$creditCard4)
{
$regexp="/^[0-9]{4}$/";
if (preg_match($regexp,$creditCard1,$creditCard2,$creditCard3,$creditCard4))//line 18
{
return TRUE;
}
else
{
echo'<script type="text/javascript">alert("Enter a valid credit card number.")</script>';
return FALSE;
}
}
$creditCard1=$_POST['creditCard1'];
$creditCard2=$_POST['creditCard2'];
$creditCard3=$_POST['creditCard3'];
$creditCard4=$_POST['creditCard4'];
$creditcard=creditcard($creditCard1,$creditCard2,$creditCard3,$creditCard4);
我收到这个错误。
Warning: preg_match() expects parameter 4 to be long, string given in C:\xampp\htdocs\SFASC2\aa.php on line 18
我无法弄清楚我做错了什么,谢谢。有很多这样的问题,但没有一个给我解决方案..而且我一直在用头撞墙,毫无疑问,忽略了显而易见的事情。