82244/how-to-print-a-debug-log
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.
Hello @kartik,
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.
Hope it helps!!
Thank You!!
PHP is compiled to byte code before ...READ MORE
Hello, Submitting multi-value form fields, i.e. submitting arrays ...READ MORE
Hello @kartik, Try-Username: root Password: (No password set). Sometimes it doesn't ...READ MORE
Hii, You can try this: $query="SELECT * FROM CountryInfo ...READ MORE
Hey @kartik, First you have to go to ...READ MORE
Named route is used to give specific ...READ MORE
Hello, This is simple you just need to ...READ MORE
Hey @kartik, Named routing is another amazing feature of ...READ MORE
A cookie is often used to identify ...READ MORE
Hello, Just use php composer.phar require For example : php ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.