logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • What is the difference between $argv and $argc? Give example?


  • Correct Answer
  • To pass the information into the script from outside, help can be taken from the PHP CLI (Command line interface) method Suppose addition of two numbers has to be passed to PHP then it can be passed like this on the command line: php addphp 2 3 Here the script name is addphp, and 2 and 3 are the numbers that has to be added by the script These numbers are available inside the script in an array called $argv This array contains all the information on the command line; the statement is stored as follows: $argv[0]=addphp $argv[1]=2 $argv[2]=3 So, $argv always contains at least one element ? the script name Then, in your script, you can use the following statements: $sum = $argv[1] + $argv[2]; echo $sum; $argc is a variable that stores the numbers of elements in $argv $argc is equal to at least 1, which is saved for the name of the script Example is $argc=3 using the above statements 


  • Technology problems


    Search Results


    • 1. What is the use of $_Server and $_Env?
    • Discuss
    • 2. What is the use of super-global arrays in PHP?
    • Discuss
    • 3. How can we increase the execution time of a php script?
    • Discuss
    • 4. What is the difference between PHP and JavaScript?
    • Discuss
    • 5. Why many companies are switching their current business language to PHP? Where PHP basically used?
    • Discuss
    • 6. Explain how to work with Permissions in PHP.
    • Discuss
    • 7. Explain Superglobal variables in PHP .
    • Discuss
    • 8. Explain how to send large amounts of emails with php.
    • Discuss
    • 9. Explain how to store the uploaded file to the final location.
    • Discuss
    • 10. Explain how to create random passwords.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment