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, ∼2079🔥, 0💬
Popular Posts:
How To Protect Special Characters in Query String in PHP? If you want to include special characters ...
What is EPUB 2.0 Metadata "dc:creator" and "dc:contributor" elements? EPUB 2.0 Metadata "dc:creator"...
How To Use an Array as a Queue in PHP? A queue is a simple data structure that manages data elements...
How to Build my "sleep" Docker image from the Alpine image? I want the container to sleep for 10 hou...
How to convert JSON Objects to PHP Associative Arrays using the json_decode() function? Actually, JS...