[Php] makes notepad your console for variable control

Source: Internet
Author: User
: This article mainly introduces [php] to make notepad your console for variable control. For more information about PHP tutorials, see. Unlike aspx and jsp, the development environment card of aspx and jsp is stuck, but they have a Visual Studio and Eclipse console that can view variable changes at any time, if php is developed using notepad, notepad, Dreamweaver, and other things, there is no console for you to observe the flow of variables. In some background pages, such as Ajax response pages, such as database method pages, for example, to check whether a variable is requested, there is no page to echo you.

In this case, you do not need to install any other tools. you can use php statements to operate on files, printing the variables or data to be debugged to a txt or html file is enough for debugging to enable or refresh the variable without listening.

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

$fp = fopen('./a.txt', 'a+b');fwrite($fp, "content=".$content);fclose($fp);
The idea is to create an a.txt file under the same directory on this page. of course, you can write it to c: // or somewhere else, or even output it. the/scripts file ends with something written, which is the meaning of the 'A + B 'parameter.

Then, write "content =" .w.content, this character string into the.txt file. of course, you think it is nice to output. of course, this output does not contain a carriage return. you can add a carriage return after the variable, for details, see the result diagram below.

Then close the pointer.

If you want to debug a $ content array, write as follows:

$fp = fopen('./a.txt', 'a+b');fwrite($fp, print_r($content, true));fclose($fp);
Print_r () can print strings and numbers, while the Array is displayed in the form of an enclosed key and a list of values, and starts with an Array. But print_r () outputs Boolean values and NULL results are meaningless, because both print "\ n ". Therefore, using the var_dump () function is more suitable for debugging.

The following figure shows some debugging results of a program, the 2 and 4 variables.

Followed by an array:


The above introduces [php] to make notepad your console for variable control, including some content, and hope to be helpful to friends who are interested in PHP tutorials.

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.