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, ∼2442🔥, 0💬
Popular Posts:
Where can I download the EPUB 2.0 sample book "The Metamorphosis" by Franz Kafka? You can following ...
Where Is the Submitted Form Data Stored in PHP? When a user submit a form on your Web server, user e...
How to make application release build with Visual Studio 2017? If you want to make a final release b...
How to attach console to a Running Container using the "docker container exec" command? I want to ge...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...