In the Windows command line window, enter and run PHP code snippets (PHP files are not required ).

Source: Internet
Author: User
In the Windows command line window, you can enter and run PHP code snippets (without a php file). sometimes, to test the effect of a PHP function, you always need to create a php file, copy the path of the file, and then access the php file through the web or run the php command.

How can I directly execute PHP code snippets without creating files? Finally, I found the method and shared it with anyone who needed it.


Prerequisites:

1. this article only describes Windows. Other operating systems are similar, but slightly different.

2. you must have installed php and set environment variables. If the downloaded executable installation package is installed, the environment variables are automatically set. If you decompress the downloaded zip package, you need to manually set the environment variable.


Now let's talk about how to enter and run PHP code snippets in the Windows command line window.


1. open the Windows command line window (you can check it yourself if you do not understand it in many ways), as shown below:


2. enter php at the command prompt and press enter, for example:


3. enter PHP code snippets. you can enter multiple lines of PHP code or paste them directly. For example:


4. This step is critical, because it is multi-line input. how do you know you want to start execution after the input is complete? A shortcut key is required.

PressEnterKey, and then pressCtrl + ZKey combination (a ^ Z character will appear on the screen at this time), and then press Enter. You can see the php running effect.

Make sure thatCtrl + ZWhen you press the key combination, enter the cursor at the beginning of the line, that is, ^ Z must be in a separate line. after you see ^ Z, press enter to execute it.

^ Z must be based onCtrl + ZThe combination key cannot be two characters: ^ and Z.

The running result is as follows:


Is this method convenient when testing small-part code? (If you want to open the command line window itself is too troublesome, then ......)


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.