PHP Programing language

adplus-dvertising
How can returning References from Function
Previous Home Next
Function can also return references in PHP. the references are interesting items in PHP. For example, say that you had a variable named $value; you could get a references to that variable with the reference operator:

$value=4;

$ref = & value;

<html>
<head>
<title>Returning references from Functions  </title>
</head>
<body>
<h1>Returning references from Functions </h1>
<?php
$value = 4;
echo "Current value:", $value, "\n";
$ref = &return_reference ($value);
$ref++;
echo "New value:", $value, "\n";
function &return_reference (& $ref)
{
return $ref;
}
?>
</body>
</html>

Output:

Previous Home Next