php 下令参数
Jun 13, 2016 pm 01:22 PM
php 命令参数
http://www.php.net/manual/zh/features.commandline.php
-f --file 解析并运行 -f 选项给定的文件名。该参数为可选参数,可以省略,仅指明需要运行的文件名即可。
以下是 PHP 二进制文件(即 php.exe 程序)提供的命令行模式的选项参数,您随时可以通过 PHP -h 命令来查询这些参数。
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 -- args when first argument
starts with - or script is read from stdin
CLI SAPI 模块有以下三种不同的方法来获取您要运行的 PHP 代码:
1.
让 PHP 运行指定文件。
php my_script.php
php -f my_script.php
以上两种方法(使用或不使用 -f 参数)都能够运行给定的 my_script.php 文件。您可以选择任何文件来运行,您指定的 PHP 脚本并非必须要以 .php 为扩展名,它们可以有任意的文件名和扩展名。
2.
在命令行直接运行 PHP 代码。
php -r 'print_r(get_defined_constants());'
在使用这种方法时,请您注意外壳变量的替代及引号的使用。
注: 请仔细阅读以上范例,在运行代码时没有开始和结束的标记符!加上 -r 参数后,这些标记符是不需要的,加上它们会导致语法错误。
3.
通过标准输入(stdin)提供需要运行的 PHP 代码。
以上用法给我们提供了非常强大的功能,使得我们可以如下范例所示,动态地生成 PHP 代码并通过命令行运行这些代码:
$ some_application | some_filter | php | sort -u >final_output.txt
以上三种运行代码的方法不能同时使用。

Artikel Panas

Alat panas Tag

Artikel Panas

Tag artikel panas

Notepad++7.3.1
Editor kod yang mudah digunakan dan percuma

SublimeText3 versi Cina
Versi Cina, sangat mudah digunakan

Hantar Studio 13.0.1
Persekitaran pembangunan bersepadu PHP yang berkuasa

Dreamweaver CS6
Alat pembangunan web visual

SublimeText3 versi Mac
Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

Topik panas

Panduan Pemasangan dan Naik Taraf PHP 8.4 untuk Ubuntu dan Debian

Cara Menyediakan Kod Visual Studio (Kod VS) untuk Pembangunan PHP
