Teach you how to use Php.exe to run PHP files

Source: Internet
Author: User
Tags php script zend
In the Windows environment, we can use Php.exe to run PHP files on the command line. Here are 2 ways to use Php.exe.
First, we can use PHP command plus PHP file + path to execute the 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 specify does not have to have the. php extension, they can have arbitrary file names and extensions.) )
Second, we can run the PHP code directly through Php-r.
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 a few places to pay special attention to. While we are using Php.exe to run PHP files, we can also enter a series of parameters to achieve different results. Let's take a brief description of these parameters.
-S (this option cannot be used with the-R parameter)
Displays the source file with syntax highlighting. This parameter uses an internal mechanism to parse the file and generate an HTML highlighted version for it and write the results to standard output. Note that this process only generates an HTML tag block of [...], and does not contain any HTML headers.
-W (this option cannot be used with the-R parameter)
Shows the source code that dropped the annotation and space.
-F
Resolves and runs the given file name. This parameter is optional and can be left blank, indicating only the file name you want to run.
-V
Standard output to write version information for PHP, PHP SAPI, and Zend.
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 to place the php.ini file, or you can specify a custom INI file directly, and its filename may not be php.ini.
-D
This parameter allows you to set the value of a variable in the php.ini file, with the syntax:-D configuration_directive[=value]
-E
Generate extended information for the debugger, and so on.
-Z
Load the Zend extension library. If only one file name is given, PHP will attempt to load the extension library from the default path of your system extension library (which is typically specified by/etc/ld.so.conf on a Linux system). If you specify a filename with an absolute path, the system's default path to the extension library will not be used. If you specify a file name with a relative path, PHP will only attempt to load an extension relative to the current directory.
-L (This parameter cannot be used with-R)
This parameter provides a convenient way to perform a syntax check on the specified PHP code. If successful, the NO syntax errors detected in string is written to standard output, and the shell return value is 0. If it fails, the 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 will not be able to check for fatal errors (such as undefined functions), use the-f argument if you want to detect the wrong name.
-M
With this parameter, PHP will print out the built-in and loaded PHP and Zend modules:
-I.
The command-line argument invokes the Phpinfo () function and prints out the result. If PHP is not working properly, we recommend that you execute the php-i command to see if there is any error message output before the information table or in the corresponding location. Note that the output is in HTML format, so the information is larger.
-R
Use this parameter to run the PHP code at the command line. You do not need to add PHP's start and End identifiers (), or you will cause syntax parsing errors.
-H
Using this parameter, you can get a complete list of command-line arguments and a simple description of how these parameters function.
PHP's command-line mode enables PHP scripts to run independently of the WEB server. If you are using a Unix system, you need to add a special line of code to the front of your PHP script so that it can be executed so that the system knows what program to run the script. You can associate the double-click property of the Php.exe and. php files under the Windows platform, or you can write a batch file to execute the script in PHP. The first line of code added to the Unix system does not affect the script running under Windows, so you can also write Cross-platform scripting with this method. Reprint please specify the source: teach you how to use Php.exe to run PHP files

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.