详解php命令行写shell实例

发布时间:2025-03-09
【相关学习推荐:php图文教程】
php 可以像java perl python 那样运行,今天发现如果我早早知道这个,或许我不会去学习java 和 python
当年学java不过为了一个程序放在服务器上,不停的跑啊跑,原来 php 也可以。
php -husage: php [options] [-f] <file> [--] [args...] php [options] -r <code> [--] [args...] php [options] [-b <begin_code>] -r <code> [-e <end_code>] [--] [args...] php [options] [-b <begin_code>] -f <file> [-e <end_code>] [--] [args...] php [options] -s <addr>:<port> [-t docroot] [router] php [options] -- [args...] php [options] -a -a run as interactive shell -c <path>|<file> look for php.ini file in this directory -n no configuration (ini) files will be used -d foo[=bar] define ini entry foo with value 'bar' -e generate extended information for debugger/profiler -f <file> parse and execute <file>. -h this help -i php information -l syntax check only (lint) -m show compiled in modules -r <code> run php <code> without using script tags <?..?> -b <begin_code> run php <begin_code> before processing input lines -r <code> run php <code> for every input line -f <file> parse and execute <file> for every input line -e <end_code> run php <end_code> after processing all input lines -h hide any passed arguments from external tools. -s <addr>:<port> run with built-in web server. -t <docroot> specify document root <docroot> for built-in web server. -s output html syntax highlighted source. -v version number -w output source with stripped comments and whitespace. -z <file> load zend extension <file>. args... arguments passed to script. use -- args when first argument starts with - or script is read from stdin --ini show configuration file names --rf <name> show information about function <name>. --rc <name> show information about class <name>. --re <name> show information about extension <name>. --rz <name> show information about zend extension <name>. --ri <name> show configuration for extension <name>.1.用php命令行的方式执行php脚本,例如/usr/bin/php test.php
缩写 php test.php
test.php
<?phpfor($i=0;$i<10;$i ){ echo $i; echo '\\\\n';}?>2.脚本开头第一行写上#!/usr/bin/php,然后可以把脚本设为可执行 chmod a x test.php,之后就可以用命令行的方式直接执行脚本了,例如./test.php
#!/usr/bin/php<?phpfor($i=0;$i<10;$i ){ echo $i; echo " java-er.com \\\\n";}?>执行一小时,看看php会不会挂,我希望一个命令行可以跑到天荒地老
#!/usr/bin/php<?phpfor($i=0;$i<360;$i ){ echo $i; sleep(10); echo " java-er.com \\\\n";}?>#!/usr/bin/php<?php var_dump($argc); //返回参数总个数 var_dump($argv); exit;?>./test.phpint(1)array(1) { [0]=> string(10) "./test.php"}./test.php a java phpint(4)array(4) { [0]=> string(10) "./test.php" [1]=> string(1) "a" [2]=> string(4) "java" [3]=> string(3) "php"}相关学习推荐:php编程(视频)
上一个:创世纪物流 创世纪物流查询
下一个:关于压敏胶带初粘性的试验方法介绍

西班牙货物空运(西班牙空运联系方式)
韩国海运港口(韩国到上海海运费用)
MSC启动生物燃料活动
win7系统电脑不能正常安装软件怎么解决(win7系统电脑不能正常安装软件吗)
木工雕刻机质量辨别方法 如何挑选木工雕刻机
螺旋微泡除污器能够使循环水系统洁净如初
一文读懂离心泵
机床主轴动平衡的方法及应用
房屋共有人有什么权利
美国出口物流,FBA头程物流是什么