Question 41Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

Which of the following is true about passing arguments by reference in PHP functions?

  1. AArguments passed by reference cannot be modified within the function.
  2. BThe original value of the argument is changed when passed by reference.
  3. CPHP does not support passing arguments by reference.
  4. DArguments passed by reference must be of type array.
Show answerHide answer

Correct answer: (B) The original value of the argument is changed when passed by reference.

Explanation

In PHP, a parameter declared with & (function f(&$x)) is a reference to the caller's variable, so changing it inside the function changes the original value. Any type can be passed by reference.

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

This is question 41 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.