PHP Command Parameters

Source: Internet
Author: User
PHP Command Parameters
http://www.php.net/manual/zh/features.commandline.php

-F--file Parse and run the-F option given the file name. This parameter is optional and can be omitted to indicate only the file name that needs to be run.



The following are the options parameters for the command-line mode provided by the PHP binaries (that is, the Php.exe program), which you can query at any time by using the Php-h command.


usage:php [Options] [-f] [args ...]

PHP [Options]-r De>[args ...] De>

PHP [Options] [--args ...]

-S Display colour 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>de>

-H This Help


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

Starts With-or script is read from stdin


The CLI SAPI module has the following three different ways to get the PHP code you want to run:


1.


Let PHP run the specified file.


PHP my_script.php


Php-f my_script.php


Both of these methods (with or without the-f parameter) are able to run a given my_script.php file. You can select any file to run, and the PHP scripts you specify do not have to be in. php as extensions, they can have arbitrary filenames and extensions.

2.


Run the PHP code directly on the command line.


Php-r ' Print_r (get_defined_constants ()); '


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


Note: Please read the above example carefully, when running the code without the start and end of the marker! With the-r parameter, these tokens are not required, plus they cause syntax errors.


3.


Provides PHP code that needs to be run through standard input (stdin).


The above usage provides us with a very powerful feature that allows us to dynamically generate PHP code and run it from the command line, as shown in the example below:


$ some_application | Some_filter | php | Sort-u >final_output.txt


The above three methods of running code cannot be used at the same time.

  • 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.