gpt4 book ai didi

php - 只有变量应该通过引用传递

转载 作者:IT老高 更新时间:2023-10-28 11:39:40 25 4
gpt4 key购买 nike

// Other variables
$MAX_FILENAME_LENGTH = 260;
$file_name = $_FILES[$upload_name]['name'];
//echo "testing-".$file_name."<br>";
//$file_name = strtolower($file_name);
$file_extension = end(explode('.', $file_name)); //ERROR ON THIS LINE
$uploadErrors = array(
0=>'There is no error, the file uploaded with success',
1=>'The uploaded file exceeds the upload max filesize allowed.',
2=>'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
3=>'The uploaded file was only partially uploaded',
4=>'No file was uploaded',
6=>'Missing a temporary folder'
);

有什么想法吗? 2天后仍然卡住。

最佳答案

explode 的结果赋值给一个变量,并将该变量传递给 end:

$tmp = explode('.', $file_name);
$file_extension = end($tmp);

问题是,end 需要引用,因为它修改了数组的内部表示(即它使 当前元素指针 指向最后一个元素) .

explode('.', $file_name) 的结果不能转为引用。这是 PHP 语言中的一个限制,可能出于简单原因而存在。

关于php - 只有变量应该通过引用传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4636166/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com