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, ∼2640🔥, 0💬
Popular Posts:
How to read Atom validation errors at w3.org? If your Atom feed has errors, the Atom validator at w3...
How to use the "Ctrl-p Ctrl-q" sequence to detach console from the TTY terminal of container's runni...
How to validate the id_token signature received from Azure AD v2.0 authentication response? You can ...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...
How To Convert a Character to an ASCII Value? If you want to convert characters to ASCII values, you...