Home  >  Article  >  Backend Development  >  Detailed explanation of usage examples returned by PHP reference

Detailed explanation of usage examples returned by PHP reference

墨辰丷
墨辰丷Original
2018-06-02 09:47:331508browse

This article mainly introduces the usage of PHP reference return, and analyzes the reference usage skills for function parameters and functions in the form of examples. It has certain reference value. Friends in need can refer to

Example 1 :

<?php
$a = 1;
function b(&$c)
{
  $c++;
  return $c;
}
$d=b($a);
$d++;
echo($a);
?>

Output: 2

Example 2:

<?php
$a = 1;
function &b(&$c)
{
  $c++;
  return $c;
}
$d=&b($a);
$d++;
echo($a);
?>

Output: 3

Summary: The above is the entire content of this article, I hope it can be useful Everyone’s learning helps.

Related recommendations:

Detailed explanation of PHP output buffer control

How to implement scheduled execution function based on sleep function in PHP

php Detailed explanation and example analysis of input and output streams

The above is the detailed content of Detailed explanation of usage examples returned by PHP reference. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn