drjyvoi734793 2013-12-27 07:57
浏览 67
已采纳

严格的标准:只有变量才能在第3行的C:\ wamp \ www \ lions \ admin \ UploadmemberHandler.php中通过引用传递

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?

  • 写回答

1条回答 默认 最新

  • dtypj3308 2013-12-27 07:59
    关注

    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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?