PHP advanced, how to use interactive mode for rapid test experiment?

Source: Internet
Author: User

Well, what, PHP is very strong, we all know ha. However, in the people who engage in PHP, naturally also to compete. Of course, I prefer to use fun to describe.

What is fast development? I think, quickly to write a few words, you can let the code run up! So, can PHP do it? The answer is yes.

For example: I want to write a "Hello,world", what is the whole? That's it:

<?   echo ' Hello, world ';

It's called fast! Of course, this has to save the file before it can be run.

Php-r "Echo ' Hello, World '"

It's called fast! A direct command runs out.

The following command basically satisfies the quick test that we need. For example, I think the Rand method's random value, whether it contains the upper and lower bounds, then, in addition to Baidu, in addition to reading the document, we can also test the truth.

Php-r "Echo rand (0, 3);"

Perform a few more times and you'll see all the possible results. Obviously, it contains, 0, 3.

This order, personally think is still very cow B. Then, sometimes, you may need to enter more code, then you should use more interaction, then you should be using PHP interactive mode.

Yes, php-a. However, in fact, php-a not all the environment can be very good operation, such as windows, can not be very good support, originally thought should be seen this:

This is actually the case:

The key is to encounter this situation, always press ENTER, or other keys, are not responding, which is embarrassing.

In fact, the workaround here is, enter Ctrl + Z Enter, and then execute.

The CTRL + Z here is CTRL + D on Linux; In this way, you can execute a test code so that you can quickly verify something.

Report:

Php-i    #  --info    the command-line argument calls the Phpinfo () function and displays the result. If PHP is not working properly, it is recommended that you execute the php-i command to see if there is any error message output before or in the information table. Note that when using CGI, the output is in HTML format, so the output information is large. 

Php-l a.php    #  --syntax-check     syntax check for specified PHP a.php code, syntax error

Php-m    #  --modules     using this parameter, PHP will print out the built-in and loaded PHP and Zend modules

Php-v    #  --version     writes the version information php,php SAPI and Zend to standard output.

In fact, scripting languages such as PHP, such as PERL,PYTHON,NODE,JS, provide interactive patterns that run validation quickly. However, if PHP does not study carefully, it should not be very aware of his function.

It's also fun to find something fun.

PHP advanced, how to use interactive mode for rapid test experiment?

Related Article

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.