You are getting this error when you passed array value in the function. Often developers end up their code with this error:
Notice: Only variables should be passed by reference in D:\xampp\htdocs\xxx\abc.php on line 9
Why these errors occur?
If you are passing a real variable into the function, you could get this error. Because only actual variable may be passed by reference.
See below code:
$fileName = ‘This-is-a-testing-string’;
$result = end(explode('-', $fileName));
echo $result;
With above code you will get this error “Notice: Only variables should be passed by reference”.
Because the end() function requires a reference, it modifies the internal representation of the array.
And explode('-', $file_name) cannot be turned into a reference. PHP language doesn’t allow this. PHP language has restricted this.
So you have to use below code instead of above
$fileName = ‘This-is-a-testing-string’;
$expFileName = explode('-', $fileName);
$result = end($expFileName);
echo $result;