Jump to content

[SOLVED] trying to pass a query string through the command line


El MoselYEE

Recommended Posts

i want to get a similar result as if i typed this in the browser: '/test.php?id=10'

 

no matter what i try, i can't seem to get it to work, here is my code:

 

$process = proc_open ('php /home/linkingp/test.php?id=10 &', Array (), $foo);
sleep(1);
proc_close ($process);

 

here are a few of the things i have tried, none of which work (first two run test.php, but without parameters, second two don't even run the script):

 

'php /home/linkingp/test.php -- id=10 &'

'php /home/linkingp/test.php -- $id=10 &'

'php -r "$id=10" /home/linkingp/test.php &'

'php -r "id=10" /home/linkingp/test.php &'

 

i have also tried setting up mod_rewrite, but for some reason that does not work either.

 

here is the manual for the command line, if it helps:

 

http://php.net/features.commandline

 

EDIT: all i need the script to do is call a PHP script and return to the current PHP page without requiring the called script to finish first. so if someone knows a better way to do this (using exec() for example), feel free to let me know...i have no idea what i'm doing so i'm all open ears...thanks!

Maybe you want to have a read of that man page yourself.

 

An example.

 

foo.php

#!/usr/bin/php
<?php

  if (isset($_SERVER['argv'])) {
    foreach($_SERVER['argv'] as $arg) {
      echo $arg."\n";
    }
  }

?>

 

Then,  to call the script. (From the terminal)

 

$ chmod 755 foo.php
$ ./foo.php this is foo

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.