How to print a debug log?
Solution 1:
A lesser known trick is that mod_php maps stderr to the Apache log. And, there is a stream for that, so file_put_contents('php://stderr', print_r($foo, TRUE))
will nicely dump the value of $foo
into the Apache error log.
Solution 2:
error_log(print_r($variable, TRUE));
might be useful
Solution 3:
You can use error_log to send to your servers error log file (or an optional other file if you'd like)
Solution 4:
If you are on Linux:
file_put_contents('your_log_file', 'your_content');
or
error_log ('your_content', 3, 'your_log_file');
and then in console
tail -f your_log_file
This will show continuously the last line put in the file.