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, 1966🔥, 0💬
Popular Posts:
How to add an API to an API product for internal testing on the Publisher Portal of an Azure API Man...
What Is session_register() in PHP? session_register() is old function that registers global variable...
How to use the RSS Online Validator at w3.org? You can follow this tutorial to learn how to use the ...
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
How to login to the Developer Portal internally by you as the publisher? Normally, the Developer Por...