"PHP" makes Notepad the console for you to control variables

Source: Internet
Author: User
PHP is not like aspx with jsp,aspx and JSP development environment card is stuck, but they have a Visual Studio and Eclipse console can see the change of variables at any time, PHP if using Notepad, Notepad or Dreamweaver and other things developed , there is no console for you to observe the flow of variables. In some background pages, such as the AJAX response page, such as the database method page, for example, to see if a variable is a request, there is no page for you to echo.

At this point, there is no need to install any tools, the use of PHP operation file statements, to debug the variables or data to print to a txt or HTML we do not listen to open or refresh to observe the variables, it is enough to debug.

If you want to debug the $content variable, write this:

$fp = fopen ('./a.txt ', ' a+b '); Fwrite ($fp, "content=". $content); fclose ($FP);
It means to create a a.txt under the same directory on this page, of course, if you're uncomfortable, you can write to c:/or somewhere, and even output to. A.html, and then open a browser, the output once viewed, keep watching, has reached the effect of rapid debugging, if there is already a.txt, and a.txt have content, then at the end of this a.txt file to write things, this is the meaning of the ' a+b ' parameter.

Then, put "content=". $content variable, this string is written to a.txt this file, of course, you feel good-looking how to output, of course, this output is not with a carriage return, you can also fill a return after the variable, details see the following result diagram.

Then close the pointer.

If the thing you are debugging is a $content array, write this:

$fp = fopen ('./a.txt ', ' a+b '); fwrite ($fp, Print_r ($content, True)); fclose ($FP);
Where: Print_r () can simply print the string and the number, and the array is displayed in the enclosed key and the list of merits, starting with an array. However, the result of Print_r () output Boolean and null is meaningless because it is all printed "\ n". Therefore, using the Var_dump () function is more suitable for debugging.

The following is a partial debug result diagram of one of my programs, the 2 and 4 variables

After that is an array:


The above describes the "PHP" to make Notepad your control variable of the console, including the aspects of the content, I hope to be interested in PHP tutorial friends to help.

  • 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.