Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
16
Help us understand the problem. What is going on with this article?
@tokoro10g

コマンドライン上からPHPスクリプトに$_GETを渡す

More than 5 years have passed since last update.

デバッグのためにターミナルからPHPのスクリプトにGETリクエストの変数を渡したいことがたまにある.
調べてみたらphp-cgiなるものをインストールすると幸せになれるらしいのでやってみた.

Ubuntu(-14.04)

$ sudo apt-get install php-cgi

Ubuntu(14.10)

$ sudo apt-get install php5-cgi

Arch Linux

$ yaourt -S php-cgi

軽くテスト

test.php
<?php
print_r($_GET);
$ php-cgi test.php hoge=fuga foo=bar num=1
X-Powered-By: PHP/5.3.10-1ubuntu3.9
Content-type: text/html

Array
(
    [test_php] =>
    [hoge] => fuga
    [foo] => bar
    [num] => 1
)

参考:
http://serverfault.com/questions/187025/how-to-pass-get-variables-to-a-php-script-via-the-command-line/187038#187038

16
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
16
Help us understand the problem. What is going on with this article?