开发者

Passing arguments in php script inside ruby

In my ruby code, i am using Backticks (`) to execute a php script like:

result = `php #{RAILS_ROOT}/lib/php/test.php`

How can i pass 开发者_开发问答arguments in this php script?

How can i grab the arguments inside the (php) script?

thanks!


Check out Using PHP from the command line in the PHP manual.

This page has a full example:

 # This will not execute the given code but will show the PHP usage
$ php -r 'var_dump($argv);' -h
Usage: php [options] [-f] <file> [args...]
[...]

# This will pass the '-h' argument to your script and prevent PHP from showing it's usage
$ php -r 'var_dump($argv);' -- -h
array(2) {
  [0]=>
  string(1) "-"
  [1]=>
  string(2) "-h"
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜