PHP Programing language

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

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: