I'd like to debug some PHP code, but I guess printing a log to screen or file is fine for me.
How should I print a log in PHP code?
The usual print
/printf
seems to go to HTML output not the console.
I have Apache server executing the PHP code.
I'd like to debug some PHP code, but I guess printing a log to screen or file is fine for me.
How should I print a log in PHP code?
The usual print
/printf
seems to go to HTML output not the console.
I have Apache server executing the PHP code.
You need to change your frame of mind. You are writing PHP, not whatever else it is that you are used to write. Debugging in PHP is not done in a console environment.
In PHP, you have 3 categories of debugging solutions:
Learn to use those instead of trying to make PHP behave like whatever other language you are used to.
If you don't want to integrate a framework like Zend, then you can use the trigger_error method to log to the php error log.
You can use
or if you want to print that statement in an log you can use
Simply way is trigger_error:
but you can't put arrays or Objects therefore use
You can use:
If you are on Linux:
or
and then in console
This will show continuously the last line put in the file.