Php command parameters

Source: Internet
Author: User
Php command parameter http://www.php.net/manual/zh/features.commandline.php-f--file#and run the file name specified by -f. This parameter is optional and can be omitted. it only specifies the name of the file to be run. The following is a PHP binary file (php command parameter
Http://www.php.net/manual/zh/features.commandline.php

-F -- file parses and runs the file name specified by the-f option. This parameter is optional and can be omitted. it only specifies the name of the file to be run.



The following are the command line mode option parameters provided by the PHP binary file (php.exe program). you can use the PHP-h command to query these parameters at any time.


Usage: php [options] [-f] [args...]

Php [options]-r DE> [args...] DE>

Php [options] [-- args...]

-S Display color syntax highlighted source.

-W Display source with stripped comments and whitespace.

-F Parse.

-V Version number

-C | Look for php. ini file in this directory

-A Run interactively

-D foo [= bar] Define INI entry foo with value 'bar'

-E Generate extended information for debugger/profiler

-Z Load Zend extension.

-L Syntax check only (lint)

-M Show compiled in modules

-I PHP information

-R DE> Run php de> without using script tags DE>

-H This help


Args... Arguments passed to script. Use -- args when first argument

Starts with-or script is read from stdin


The cli sapi module has the following three methods to obtain the PHP code you want to run:


1.


Run the specified file in PHP.


Php my_script.php


Php-f my_script.php


The above two methods (using or without the-f parameter) can run the given my_script.php file. You can select any file to run the script. the PHP script you specified does not have to use. php as the extension. they can have any file name and extension.

2.


Run the PHP code directly on the command line.


Php-r 'print _ r (get_defined_constants ());'


When using this method, pay attention to the substitution of shell variables and the use of quotation marks.


Note: read the preceding example carefully. there is no start or end mark when running the code! After the-r parameter is added, these tokens are not required, and adding them will lead to syntax errors.


3.


Provide the PHP code to be run through standard input (stdin.


The above usage provides us with very powerful functions, so that we can dynamically generate PHP code and run the code through the command line as follows:


$ Some_application | some_filter | php | sort-u> final_output.txt


The preceding three methods for running code cannot be used at the same time.

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.