Only Variables can be passed by reference error

前端 未结 2 1179
一生所求
一生所求 2020-12-07 01:26

An error occurred in script \'/usr/local/apache2/htdocs/read.php\' on line 197: Only variables should be passed by reference (line 196 is $ext = strtolo

相关标签:
2条回答
  • 2020-12-07 01:51

    You need to make the result of explode() a variable before you pass it on

    $var = explode('.',$filename);
    $ext = strtolower(array_pop($var));
    
    0 讨论(0)
  • 2020-12-07 01:51

    That code is passing the result of the explode function (a value) into array_pop, but array_pop expects an array variable (by reference), not a value. (The & in the array_pop declaration tells us that it's expecting to accept a reference.)

    You can fix it by using an array variable to store the result of explode, and then passing that into array_pop.

    0 讨论(0)
提交回复
热议问题