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, 1429👍, 0💬
Popular Posts:
How to run CMD Commands in Dockerfile to change Windows Docker images? When building a new Windows i...
How to Instantiate Chaincode on BYFN Channel? You can follow this tutorial to Instantiate Chaincode ...
Where Is the Submitted Form Data Stored in PHP? When a user submit a form on your Web server, user e...
How to use the "return-response" Policy statement to build the response from scratch for an Azure AP...
Where Can I get a copy of the RSS XML Schema? RSS XML Schema is an XML Schema that defines how an RS...