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, 1965🔥, 0💬
Popular Posts:
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...
Can You Add Values to an Array without Keys in PHP? Can You Add Values to an Array with a Key? The a...
Where to find tutorials on Python programming language? I want to learn Python. Here is a large coll...
How to use "xsl-transform" Azure API Policy Statement? The "xsl-transform" Policy Statement allows y...
How To Pass Arrays By References? in PHP? Like normal variables, you can pass an array by reference ...