更新时间:2023-02-16 22:25:03
问题是代码给了 pack()
(我指的是最后一个参数)一个字符,一个数组, 和一个整数.由于代码 C
需要 4 个字符,这就是错误的原因.
The problem is that the code is giving to pack()
(I am referring the the last arguments) a character, an array, and an integer. As the code C
wants 4 characters, that is the cause of the error.
代码应该类似于
$split = preg_split('/\./','10.2.1.1', -1, PREG_SPLIT_NO_EMPTY);
echo pack("SSA12AC4L",
'25',
'00001',
'2u7wx6fd94fd',
'f',
$split[0],
$split[1],
$split[2],
$split[3],
time()+60*60
);
那么,在这种情况下没有理由使用 preg_split()
,当可以使用 explode()
代替时.正则表达式应仅在绝对必要时使用,因为与其他字符串函数相比,正则表达式函数速度较慢.
Then, there is no reason to use preg_split()
in this case, when explode()
can be used instead. Regular expressions should be used only when strictly necessary because the regular expression functions are slower, compared to other string functions.