-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 等等。用来处理这些数据会方便许多。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool