I don't know what's going on with my PHP. I'm using a bunch of classes and a semi-MVC framework that I developed myself (as an experiment). So the PHP file is including a lot of class files.
My PHP line numbers for error messages are completely off and therefore useless and making it impossible for me to debug. For example, right now I'm getting an error message that says:
`Parse error: syntax error, unexpected ')' in /view.php on line 209
The only problem is: there is no ')' anywhere near line 209. Even worse, if I put die()
on line 200 or so, it still gives me an error message, now pushed down to line 210. So clearly the line of code is being taken into account, yet for some reason it's not dying.
Another thing is, it's including a header.php file prior to this line. The header file basically just outputs some HTML, and works fine on other pages. Yet on this page, it doesn't even output the header; it's just dying with a blank page and that error message.
Is there anything I can do to use more reliable debugging? If I could have an accurate line number, I'm sure I'd find the bug easily.
Edit: I found the bug. The point of this question is not to solve the unexpected ')' bug. The point is: why are the line numbers inaccurate? The actual error message was on line 218, not 209 or 210.
To turn off or disable error reporting in PHP, set the value to zero. For example, use the code snippet: <? php error_reporting(0); ?>
To Show All PHP Errors Adding these lines to your PHP code file is the quickest way to output all PHP errors and warnings: ini_set ('display_errors', 1); ini_set ('display_startup_errors', 1); error_reporting (E_ALL); The ini_set() function will attempt to override the PHP ini file's configuration.
PHP Fatal Errors are coding errors so severe that the server cannot display the site properly - they are usually caused by conflicting or poorly designed extensions, . htaccess misconfigurations and things like that.
It's your line endings. Open up a program where you can change the line endings and change it to that of the server and the line number will be correct. I don't know about windows, but on mac you can change line endings using TextWrangler (or BBEdit) and on linux using gedit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With