PHP Programing language

adplus-dvertising
How Can Passing by Reference
Previous Home Next
When you pass data to a function, what's really passed is a copy of that data. So, for example, if you pass a variable, a copy is made of that variable, and that copy is actually passed to the function.

For example:

<html>
<head>
<title>Passing Reference to Functions </title>
<body>
<h1>Passing Reference to Functions </h1>
<?php
$value = 4;
echo "Before the call, \$value holds $value <br>";
squarer ($value);
echo "After the call, \$value holds $value <br>";
function squarer (&$number)
{
$number *= $number;
}
?>
</body>
</html>

Output:

Previous Home Next