unread
Hello!
I've been thinking that some errors in PHP are very difficult to
understand. Especially when we use two equal functions with different
arguments on the same line. The error does not make it clear where the
error is.
$strVariable = 'hello';
$nullVariable = null;
return strlen($strVariable) - strlen($nullVariable);
The second strlen()
will causes an error: "strlen() expects parameter 1 to
be string, null given - line 107".
So I thought of two possible solutions:
- Improve the error description, displaying parameters and information
that are easy to reuse (eg. variables).
- "strlen($nullVariable) expects parameter 1 to be string, null given -
line 107"
- Indicate the offset from where the function was called, along with the
line (which already exists).
- "strlen() expects parameter 1 to be string, null given - line 107:30"
I believe that the second solution is the simplest to be implemented and
already solves the problem enough.
Atenciosamente,
David Rodrigues