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.
2016-12-08, 1214👍, 0💬
Popular Posts:
Where to find tutorials on Using Azure API Management Developer Portal? Here is a list of tutorials ...
How to add request URL Template Parameters to my Azure API operation to make it more user friendly? ...
How to add images to my EPUB books Images can be added into book content using the XHTML "img" eleme...
What is Azure API Management Publisher Portal 2017 version? Azure API Management Publisher Portal is...
How to use urllib.parse.urlencode() function to encode HTTP POST data? My form data has special char...