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
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top