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, 1661👍, 0💬
Popular Posts:
Where to get a JSON.stringify() Example Code in JavaScript? Here is a good JSON.stringify() example ...
How to use the "send-one-way-request" Policy statement to call an extra web service for an Azure API...
Where to find tutorials on JSON (JavaScript Object Notation) text string format? I want to know how ...
How to create a new API on the Publisher Dashboard of an Azure API Management Service? If you are ne...
How to use the urllib.request.Request object to build more complex HTTP request? The urllib.request....