PHP Shell初体验

作者 : admin 于 2008-05-25 16:59:51 标签: , ,
2008
05-25

在linux(centos5)上编译安装 php-5.2.6.tar.gz ,configure参数一定要带上 –enable-cli

完成后,php所在目录 /usr/local/bin/php

运营 ./php -v 显示php版本信息,证明安装成功

编写我的第一个php shell脚本
#!/usr/local/bin/php -q
echo “Hello World!”;
?>

保存为 test.sh
运行,屏幕会 回显 Hello World!

在命令行下,不会存在get post之类的动作,除非参数写到页面内,而php恰巧提供了这样的命令行参数接口,$argv
修改test.sh
#!/usr/local/bin/php -q
print_r($argv);
?>

加参数运行 ./test.sh t1 t2 ,回显为

Array
(
[0] => ./test.sh
[1] => t1
[2] => t2
)

发表评论




XHTML:你可以使用的标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(若看不到验证码,请重新加载页面。)