How can the error message "Strict Standards: Only variables should be passed by reference" be resolved in PHP?
The error message "Strict Standards: Only variables should be passed by reference" occurs when a function is expecting a variable to be passed by reference, but a non-variable (such as a value or an expression) is passed instead. To resolve this issue, you should ensure that only variables are passed by reference to functions that require it.
// Incorrect usage that triggers the error
function increment(&$num) {
$num++;
}
$value = 5;
increment(5); // This will trigger the error
// Corrected code
$number = 5;
increment($number); // This will not trigger the error
Keywords
Related Questions
- What are the potential pitfalls of using PEAR for PHP installations, especially in conjunction with Xampp?
- How can the use of register_globals in PHP scripts impact functionality, and what are the recommended alternatives to this deprecated feature?
- What are the potential challenges of implementing live chat, video chat, and telephony features using PHP?