开发者

Passing arguments in php script inside ruby

开发者 https://www.devze.com 2023-01-24 09:13 出处:网络
In my ruby code, i am using Backticks (`) to execute a php script like: result = `php #{RAILS_ROOT}/lib/php/test.php`

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

精彩评论

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