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, 1430👍, 0💬
Popular Posts:
How to create Hello-2.0.epub with WinRAR? I have all required files to create Hello-2.0.epub. To cre...
How to create the Hello-3.0.epub package? I have all required files to create Hello-3.0.epub. To cre...
How to add request URL Template Parameters to my Azure API operation to make it more user friendly? ...
How to use the "@(...)" expression in Azure API Policy? The "@(...)" expression in Azure API Policy ...
How to build a test service operation to dump everything from the "context.Request" object in the re...