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 can use the php curl module to make calls to http://liveoutput.com/. This works great in an secure, corporate environment where certain restrictions in the php.ini exists that restrict usage of
file_put_contents
.This a great tool for debugging & logging php: PHp Debugger & Logger
It works right out of the box with just 3 lines of code. It can send messages to the js console for ajax debugging and can replace the error handler. It also dumps information about variables like var_dump() and print_r(), but in a more readable format. Very nice tool!
You can also write to a file like this:
Make sure the proper permissions are set so php can access and write to the file (
775
).