Only variable references should be returned by reference - Codeigniter
This error message in Codeigniter indicates that you are attempting to return a variable by reference, but only variable references can be returned by reference.
In PHP, you can return a reference to a variable by prefixing the variable name with an ampersand (&
) in the function definition. However, you can only return a reference to a variable, not to a literal or an expression.
Here's an example of correct usage:
<?php
function &get_instance()
{
return $this;
}
Here's an example of incorrect usage that would trigger the error message:
<?php
function &get_instance()
{
return 5 + 10; // cannot return a reference to an expression
}
If you are seeing this error message, it means that you are attempting to return a reference to something that is not a variable. To fix the error, you will need to modify your code to ensure that you are only returning references to variables.