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, 1519🔥, 0💬
Popular Posts:
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...
How to use the RSS Online Validator at w3.org? You can follow this tutorial to learn how to use the ...
How to extend json.JSONEncoder class? I want to encode other Python data types to JSON. If you encod...
How to run PowerShell Commands in Dockerfile to change Windows Docker images? When building a new Wi...
Can Two Forms Be Nested? Can two forms be nested? The answer is no and yes: No. You can not nest two...