query string value from php command line
Results 1 to 3 of 3

Thread: query string value from php command line

  1. #1
    Senior Member
    Join Date
    Jun 2000
    Posts
    65,357

    query string value from php command line

    I have a question about using php from the command line.

    I want to be able to call the php interpreter from the command line and pass values from the query string to the script.

    Say I want to test a page that needs a session id to generate properly. From the browser I type in

    http://domain.com/myscript.php?session_id=12345

    how can I get the session_id to be recognized by my script that expects the variable to be instantiated when it parses the query string?

    I've tried setting the QUERY_STRING environment variable and then running php (at least in windows) and that doesn't seem to work.

    c:\> set QUERY_STRING id=12345
    c:\> php.exe myscript.php

    I've tried passing variables as additional arguments (which seems the most intuitive to me)

    c:\> php.exe myscript.php session_id=12345

    There has to be an easy way to do this. Anyone know how?

  2. #2
    Member
    Join Date
    Jan 2001
    Posts
    73

    RE: query string value from php command line

    Easy answer! There was a PHPBuilder on this subject:

    Using PHP As A Shell Scripting Language
    http://www.phpbuilder.com/columns/darrell20000319.php3

  3. #3
    Senior Member
    Join Date
    Jun 2000
    Posts
    65,357

    RE: query string value from php command

    Thanks. I was able to import the shell variable QUERY_STRING in linux, but I suspect my problem in windows must have been needing to set the php.ini file:

    register_globals=On


    I found this help at:

    http://www.phpbuilder.com/annotate/message.php3?id=1008148


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •