in Education by
I'm trying to run PHP from the command line under Windows XP. That works, except for the fact that I am not able to provide parameters to my PHP script. My test case: echo "param = " . $param . "\n"; var_dump($argv); I want to call this as: php.exe -f test.php -- param=test But I never get the script to accept my parameter. The result I get from the above script: PHP Notice: Undefined variable: param in C:\test.php on line 2 param = '' array(2) { [0]=> string(8) "test.php" [1]=> string(10) "param=test" } I am trying this using PHP 5.2.6. Is this a bug in PHP 5? The parameter passing is handled in the online help: Note: If you need to pass arguments to your scripts you need to pass -- as the first argument when using the -f switch. This seemed to be working under PHP 4, but not under PHP 5. Under PHP 4 I could use the same script that could run on the server without alteration on the command line. This is handy for local debugging, for example, saving the output in a file, to be studied. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Why do you have any expectation that param will be set to the value? You're responsible for parsing the command line in the fashion you desire, from the $argv array.

Related questions

0 votes
    I'm trying to run PHP from the command line under Windows XP. That works, except for the fact ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    I'm trying to run PHP from the command line under Windows XP. That works, except for the fact ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    I'm trying to run PHP from the command line under Windows XP. That works, except for the fact ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I have a code and I need to pass the arguments like name from terminal. Here is my code and how ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 27, 2022 in Education by JackTerrance
0 votes
    I have a code and I need to pass the arguments like name from terminal. Here is my code and how ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. What are ... can do this? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    Write a Java program to read two strings from command line arguments and check the equality of two strings using string function. Select the correct answer from above options...
asked Dec 9, 2021 in Education by JackTerrance
0 votes
    Question No. 6 Which of the following module is not used for parsing command line arguments automatically ? O ... argparse O getopt Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    Which of this method is given parameter via command line arguments? (a) main() (b) recursive() ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which of these data types is used to store command line arguments? (a) Array (b) Stack (c) String ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which class allows parsing of command line arguments? (a) Args (b) JCommander (c) Command Line (d) ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What are command line arguments in C Programming?...
asked Jan 18, 2021 in Technology by JackTerrance
0 votes
    What is the first string in the argument vector w.r.t command line arguments in C?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    What are command line arguments in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    Is it possible in Windows to get a folder's size from the command line without using any 3rd party ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
...