How to use php.exe to run the php file

Source: Internet
Author: User
In Windows, we can use php.exe to run PHP files in the command line. Next we will introduce two methods to use php.exe. First, we can use the php command and php file + path to execute a specific php file. in windows, we can use php.exe in the command line to run the php file. Next we will introduce two methods to use php.exe.
First, we can use the php command and php file + path to execute a specific php file.
The specific running code is as follows: php \ wamp \ www \ index. php (you can select any file to run. the PHP script you specified does not have to run. php is the extension, and they can have any file name and extension .)
Second, we can use php-r to directly run php code.
The specific running code is as follows: php-r "echo 111111 ;"
After learning two ways to use php.exe to run PHP files, we still have some special notes. While using php.exe to run PHP files, we can also enter a series of parameters to achieve different results. Next we will introduce these parameters one by one.
-S (this option cannot be used together with the-r parameter)
Displays source files with syntax highlighted colors. This parameter uses the internal creation mechanism to parse the file, generate an HTML highlighted version for it, and write the result to the standard output. Note that all you have done in this process is to generate an HTML tag block [...] and does not contain any HTML header.
-W (this option cannot be used together with the-r parameter)
Displays the source code without comments and spaces.
-F
Parse and run the given file name. This parameter is optional and can be left unspecified. it only specifies the name of the file to be run.
-V
Standard output of writing PHP, php sapi, and Zend version information.
For example:
$ Php-v
PHP 4.3.0-dev (cli), Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies
-C
With this parameter, you can specify a directory for storing the php. ini file, or directly specify a custom INI file whose file name may not be php. ini.
-D
You can use this parameter to set the variable value in the php. ini file. The syntax is-d configuration_directive [= value].
-E
Generate extension information for the debugger.
-Z
Load the Zend Extension Library. If only one file name is given, PHP will try to extend the default path of the library from your system (in Linux, this path is usually set by/etc/ld. so. specified by conf) to load the extension Library. If you specify a file name using an absolute path, the default path of the System Extension library will not be used. If the file name specified by the relative path is used, PHP only attempts to load the extension Library relative to the current directory.
-L (this parameter cannot be used with-r)
This parameter provides a convenient way to check the syntax of the specified PHP code. If successful, No syntax errors detected in string is written to the standard output, and the shell return value is 0. If an error occurs, Errors parsing and internal parser error messages are written to the standard output together, and the shell return value is not set to 255. This parameter cannot be used to check for fatal errors (for example, undefined functions). If you want to detect a name error, use the-f parameter.
-M
With this parameter, PHP prints out the built-in and loaded PHP and Zend modules:
-I
The command line parameter calls the phpinfo () function and prints the result. If PHP does not work properly, we recommend that you run the php-I command to check whether any error information is output before or where the information table is located. Note that the output content is in HTML format, so the output information is too large.
-R
You can use this parameter to run PHP code in the command line. You do not need to add the start and end identifiers () of PHP. otherwise, syntax parsing errors may occur.
-H
With this parameter, you can get a complete list of command line parameters and a brief description of the functions of these parameters.
The PHP command line mode enables PHP scripts to run independently of WEB servers. If you use a Unix system, you need to add a special line of code at the beginning of your PHP script so that it can be executed, in this way, the system will know what program to use to run the script. On Windows, you can associate php.exe with the double-click attribute of the. php file. you can also compile a batch file to execute scripts in PHP. The first line of code added to the Unix system does not affect the running of the script in Windows. Therefore, you can use this method to compile a cross-platform scripting program.

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.