1. 程式人生 > >讀取文件後綴名報錯:Notice: Only variables should be passed by reference in

讀取文件後綴名報錯:Notice: Only variables should be passed by reference in

-s size pre sse 手冊 strtol sed col only

在寫讀取後綴名函數時遇到此通知錯誤:

function getExt($fileName){
    // $tmp = explode(".", $fileName);
    return strtolower(end(explode(".", $fileName)));
}

技術分享

解決方法:經過手冊查詢,因為end函數需要傳入的參數是一個數組通過引用傳遞的,只有真正的變量才能以引用傳遞,所以必須傳入一個真正的變量。修改後代碼如下就沒有此錯誤顯示了。

function getExt($fileName){
    // $tmp = explode(".", $fileName);
    return
strtolower(end(explode(".", $fileName))); }

讀取文件後綴名報錯:Notice: Only variables should be passed by reference in