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