Tools, FAQ, Tutorials:
Returning a Reference from a Function in PHP
How To Return a Reference from a Function? in PHP?
✍: FYIcenter.com
To return a reference from a function, you need to:
Here is a PHP script on how to return a reference from a function:
<?php $favor = "vbulletin"; function &getFavorRef() { global $favor; return $favor; } $myFavor = &getFavorRef(); print("Favorite tool: $myFavor\n"); $favor = "phpbb"; print("Favorite tool: $myFavor\n"); ?>
This script will print:
Favorite tool: vbulletin Favorite tool: phpbb
As you can see, changing the value in $favor does affect $myFavor, because $myFavor is a reference to $favor.
⇒ Specifying Argument Default Values in PHP
⇐ Function Returns Data by Value in PHP
2016-12-08, 2051🔥, 0💬
Popular Posts:
How to build a PHP script to dump Azure AD 2.0 Authentication Response? If you are use the Azure-AD-...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...
How to send an FTP request with the urllib.request.urlopen() function? If an FTP server supports ano...
What is the standard to map XML repeating elements to JSON values? There seems to be no industry sta...