But this is not an error - PHP treats it as a "notice". this is the best answer for me, the string manipulations just add little mess in the code, Weird. If all you want is the last item of the array without affecting the internal array pointer just do the following: If you need to get a reference on the first or last element of an array, use these functions because reset() and end() only return you a copy that you cannot dereference directly: I found that the function end() is the best for finding extensions on file name. Has depleted uranium been considered for radiation shielding in crewed spacecraft beyond LEO? This is not a bug. : No other expressions should be passed by reference, as the php - Only variables should be passed by reference - Stack Overflow The array. https://www.php.net/manual/en/function.array-key-last.php. They may be perfectly valid but they're more complicated to use and read. [2006-11-27 15:46 UTC] tony2001@php.net Thank you for taking the time to write to us, but this is not a bug. It's pretty simple Just use a variable in there: Or use a dummy variable (as shown in Codex): Thanks for contributing an answer to WordPress Development Stack Exchange! correctly pass the argument by reference. Same problem here, made a test site with XAMPP on PHP 8.0 (worked) and cloned my site to a 7.4 environment. function definitions. Connect and share knowledge within a single location that is structured and easy to search. The output of explode() is not an actual array. Please check again the thread youre following up on. Just as you can't index the array immediately, you can't call end on it either. The result of explode('. How to check for #1 being either `d` or `h` with latex3? PHP: " variables can be passed by reference" in str_replace()? how to fix error "called incorrectly, should not be accessed directly"? This solution is valid, however incorrect. This is different from finding the file extension. Your code sample is not affected by the change in parentheses handling which you originally linked to.
php only variables can be passed by reference