1

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!

1 Answer 1

2

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"
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.