search
Homephp教程php手册php 用做脚本时的一些技巧

php 用做脚本时的一些技巧

Jun 06, 2016 pm 07:54 PM
phpparameterCanimplementSkillScript

-r 参数可以直接执行一段代码,不需要 ?php 例如 php -r 'phpinfo();' -R 参数可以对标准输入的每一行执行一段代码。会有两个变量,$argi 是行号, $argn 是当前行内容。 例如 ls | php -R 'echo "$argi/t$argn/n";' -B,-E 分别表示在整个处理输入的开始和

-r 参数可以直接执行一段代码,不需要 例如 php -r 'phpinfo();'

-R 参数可以对标准输入的每一行执行一段代码。会有两个变量,$argi 是行号, $argn 是当前行内容。
例如 ls | php -R  'echo "$argi/t$argn/n";'

-B,-E 分别表示在整个处理输入的开始和结束时执行的脚本。
比如 ls | php -R  'echo "$argi/t$argn/n";' -B 'echo "Begin/n";' -E 'echo "End/n";'
结果会是

Begin
1       a.txt
2       b.txt
3       c.txt
...
End

更多参数可以看 man php 。

php 用在脚本里有啥好处呢?php 带了很多 web 应用常用的函数。比如转义 html ,url 等等。用来处理这些数据会方便许多。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version