4
In PHP, when an error occurs, usually the line of the script where it occurred is informed:
Undefined index 'a' in line 5
But there are times when error is returned on line 0 (zero).
Example:
Fatal error: Call to a Member Function items() on a non-object in File.php on line 0
By the time I work with PHP, I know very well that the line count of the script starts from the 1
and not of 0
Example:
<?= __LINE__ ?> // Retorna 1
Why PHP sometimes returns Erro in Line 0
? Is it a bug? Or does it have logical explanation?
Hello friend, please it would be easier to help you if you put your codes so we can see where possibly this mistake.
– Tiago
Take a look at the second example
– Wallace Maxters
I don’t care about a specific mistake. I actually want to know where is this so-called line 0.
– Wallace Maxters
Converting errors into exceptions can help (I caught from here). My experience with scripting languages is that sometimes the engine gives an error on something you are pulling from another file, and then it fails to get the reference to the exact point where the error occurred and indicates zero line. I don’t know if PHP pre-compiles more if doing this is another indication that it might be something like.
– Oralista de Sistemas
Who gave the negative, could at least do the kindness to leave a feedback there, to see what can be arranged in the question.
– Wallace Maxters
Usually when it makes use of
call_user_function()
,eval()
,overload
, and things like that make the flow of the code obscure. The interpreter cannot get the line from which the interruption or the notice error originated. But I can’t say it’s that for your specific case. And of course, I’m not saying it’s bad to use the functions mentioned. Try to give adebug_backtrace()
and goes in the race even sticking breakpoints by the codes. And shares with us what has found heheh– Daniel Omine