
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
How to pass reference parameters PHP?
In PHP, use &$ in function parameter to pass reference parameters.
Example
The PHP code is as follows
<!DOCTYPE html> <html> <body> <?php function referenceDemo(&$number){ $number=$number+100; return $number; } $number=900; echo "The actual value is=",$number,"<br>"; $result=referenceDemo($number); echo "The modified value is=",$result; ?> </body> </html>
Output
This will produce the following output
The actual value is=900 The modified value is=1000
- Related Articles
- How do we pass parameters by reference in a C# method?
- What is Pass By Reference and Pass By Value in PHP?
- How do you pass objects by reference in PHP 5?
- How to use Reference Parameters in C++?
- What is the difference between pass by value and reference parameters in C#?
- Value parameters vs Reference parameters vs Output Parameters in C#
- How to pass parameters to a method in C#?
- How to pass the parameters in the PowerShell function?
- How to pass optional parameters to a function in Python?
- How to pass pointers as parameters to methods in C#?
- How to pass keyword parameters to a function in Python?
- How to pass an array by reference in C++
- How to pass arguments by reference in Python function?
- How to pass arguments by reference in a Python function?
- Pass by reference vs Pass by Value in java

Advertisements