Tools, FAQ, Tutorials:
Defining an Argument as a Reference in PHP
Can You Define an Argument as a Reference Type? in PHP?
✍: FYIcenter.com
You can define an argument as a reference type in the function definition. This will automatically convert the calling arguments into references. Here is a PHP script on how to define an argument as a reference type:
<?php
function ref_swap(&$a, &$b) {
$t = $a;
$a = $b;
$b = $t;
}
$x = "PHP";
$y = "JSP";
print("Before swapping: $x, $y\n");
ref_swap($x, $y);
print("After swapping: $x, $y\n");
?>
This script will print:
Before swapping: PHP, JSP After swapping: JSP, PHP
⇒ Passing Arrays to Function in PHP
⇐ Passing Variables by References in PHP
2016-12-24, ∼2389🔥, 0💬
Popular Posts:
Can Two Forms Be Nested? Can two forms be nested? The answer is no and yes: No. You can not nest two...
Where to find tutorials on JSON (JavaScript Object Notation) text string format? I want to know how ...
How to troubleshoot the Orderer peer? The Docker container terminated by itself. You can follow this...
How to add request URL Template Parameters to my Azure API operation to make it more user friendly? ...
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a...