Detailed explanation of usage examples returned by PHP reference

墨辰丷
Release: 2023-03-29 11:44:02
Original
1458 people have browsed it

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);
?>
Copy after login

Output: 2

Example 2:

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!