Bird
0
0

Which statement about modifying arrays by reference in PHP is true?

hard📝 Conceptual Q10 of 15
PHP - Arrays
Which statement about modifying arrays by reference in PHP is true?
AAssigning an array element by reference allows changes to affect the original array.
BArrays cannot be modified by reference in PHP.
CAssigning by reference creates a copy of the array element.
DReferences only work with objects, not arrays.
Step-by-Step Solution
Solution:
  1. Step 1: Understand references in PHP arrays

    Assigning an element by reference means changes to the reference affect the original array element.
  2. Step 2: Evaluate other options

    PHP supports references for arrays; it does not create copies when assigned by reference; references work with arrays and objects.
  3. Final Answer:

    Assigning an array element by reference allows changes to affect the original array. -> Option A
  4. Quick Check:

    References modify original array elements [OK]
Quick Trick: References link variables to original data [OK]
Common Mistakes:
  • Thinking arrays can't be referenced
  • Confusing reference assignment with copying
  • Believing references only apply to objects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes