Shell运行/执行带参数的php脚本 [英] Shell run/execute php script with parameters

查看:231
本文介绍了Shell运行/执行带参数的php脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过shell通过参数执行一个php文件。

I need to execute a php file with parameters through shell.

这里是我将运行php文件:

here is how I would run the php file:


php -q htdocs / file.php

php -q htdocs/file.php



我需要参数'显示通过和

I need to have the parameter 'show' be passed through and


php -q htdocs / file.php?show = show_name

php -q htdocs/file.php?show=show_name

不起作用

如果有人能告诉我什么命令执行以获取php文件与设置参数,这将是非常感激。

If someone could spell out to me what command to execute to get the php file to execute with set parameters, it would be much appreciated. If not, try to lead me the right direction.

推荐答案

test.php:

print_r($argv);

Shell:

$ php -q test.php foo bar
Array
(
    [0] => test.php
    [1] => foo
    [2] => bar
)

这篇关于Shell运行/执行带参数的php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆