Strict standards: Only variables should be passed by reference in C:\wamp\www\lions\admin\UploadmemberHandler.php on line 3

StackOverflow https://stackoverflow.com/questions/20797028

  •  21-09-2022
  •  | 
  •  

I'm getting this error:

Strict standards: Only variables should be passed by reference in C:\wamp\www\lions\admin\UploadmemberHandler.php on line 3

Code:

$extension1 = end(explode(".", $_FILES["addmemberFile"]["name"])); 

How to fix this error?

有帮助吗?

解决方案

The function end() expects its parameter to be passed by reference, and in PHP, only variables can be passed by reference. You can easily fix this by storing the array in a variable and calling end() with that.

$arr = explode(".", $_FILES["addmemberFile"]["name"]);
$extension1 = end($arr); 

Even better, use the function which is specifically built for retrieving the file extension, pathinfo():

$extension1 = pathinfo($_FILES["addmemberFile"]["name"], PATHINFO_EXTENSION);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top