Tools, FAQ, Tutorials:
Function Returns Data by Value in PHP
How Values Are Returned from Functions? in PHP?
✍: FYIcenter.com
If a value is returned from a function, it is returned by value, not by reference. That means that a copy of the value is return. Here is a PHP script on how values are returned from a function:
<?php $favor = "vbulletin"; function getFavor() { global $favor; return $favor; } $myFavor = getFavor(); print("Favorite tool: $myFavor\n"); $favor = "phpbb"; print("Favorite tool: $myFavor\n"); ?>
This script will print:
Favorite tool: vbulletin Favorite tool: vbulletin
As you can see, changing the value in $favor does not affect $myFavor. This proves that the function returns a new copy of $favor.
Â
⇒Creating Your Own Functions in PHP
⇒⇒PHP Tutorials
2016-12-08, 1240👍, 0💬
Popular Posts:
What is Azure API Management Publisher Dashboard? Azure API Management Publisher Dashboard is an Azu...
How to add a new operation to an API on the Publisher Dashboard of an Azure API Management Service? ...
How to add images to my EPUB books Images can be added into book content using the XHTML "img" eleme...
How To Add Column Headers to a Table? If you want to add column headers to a table, you need to use ...
Where to find tutorials on EPUB file format? I want to know how to create EPUB books. Here is a larg...