Bird
0
0

How can you pass an argument by reference to a PHP function so that changes inside affect the original variable?

hard📝 Application Q9 of 15
PHP - Functions
How can you pass an argument by reference to a PHP function so that changes inside affect the original variable?
APrefix the parameter with & in the function definition
BUse global keyword inside the function
CPass the argument as a string
DUse static keyword in the function
Step-by-Step Solution
Solution:
  1. Step 1: Understand passing by reference

    Passing by reference means the function can modify the original variable.
  2. Step 2: Identify PHP syntax for reference

    In PHP, prefixing the parameter with & in the function definition allows passing by reference.
  3. Final Answer:

    Prefix the parameter with & in the function definition -> Option A
  4. Quick Check:

    Reference passing = & before parameter [OK]
Quick Trick: Use & before parameter to pass by reference [OK]
Common Mistakes:
  • Using global instead of reference
  • Passing by value expecting changes
  • Confusing static with reference

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes