Can't use function return value in write context?

In PHP, this error message typically occurs when a function or method that is expected to return a value is being used in a context where a value cannot be written. For example, this error can occur if you are trying to assign the return value of a function to a variable, but the function does not return a value.

Watch a course Learn object oriented PHP

This can be fixed by ensuring that the function returns a value, or by using the function in a context where a value can be written.

Another common cause of this error is trying to assign the return value of a function to a constant, which is also not possible.