How can you pass a variable by reference to a function in PHP?

  • Using the '&' symbol before the variable
  • Using the 'ref' keyword before the variable
  • Prefixing the variable with a '#' symbol
  • Using the '*' symbol before the variable
To pass a variable by reference in PHP, you use the '&' symbol before the variable name. This allows changes made to the variable within the function to affect the original variable outside the function. The other options are incorrect.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *