What good function does PHP have to output the log to the console for debugging?

Source: Internet
Author: User
JS-like Console.log (); You can add and then watch the console log debug in the PHP code line, which does not affect the normal program run.

Reply content:

JS-like Console.log (); You can add and then watch the console log debug in the PHP code line, which does not affect the normal program run.

Refer to an external PHP file chromephp
How to use:

include 'ChromePhp.php';ChromePhp::log('Hello console!');ChromePhp::log($_SERVER);ChromePhp::warn('something went wrong!');

This will enable you to see the information in the Chrome browser console. It's not been tested on Firefox.

First of all, JavaScript in the browser environment is resolvable, and PHP can not, must have a parser such as apache,php-cgi, so you want PHP in the browser control operation is not realistic.

In peacetime debugging can use echo, print_r, var_dump such functions to output the results to the page,

Of course you can also follow the Xdebug debugging tool to support breakpoint debugging

I said the way I used to dubug:

file_put_contents('log.txt',var_export($_POST,true));//这样不会中断程序的运行

Https://craig.is/writing/chrome-logger

Yes, monolog with chromephp extension

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.