Home > Backend Development > PHP Tutorial > PHP reference calls

PHP reference calls

巴扎黑
Release: 2016-11-24 13:10:23
Original
1054 people have browsed it

1.function test($arr){}
echo test(&$arr);
2.function test(&$arr){}
echo test($arr);
1 and 2 have the same effect.

3.function &test($arr){return $result;}
echo &test($a); is valid
echo test($a); returns a value, not a reference
Summary: only add before the method name when defining a method & When calling a method, a reference is returned only when & is added before the method name.

4.$a=$b;
When neither $a nor $b is reassigned, that is, when no writing operation occurs, the same as $a =&$b is the same, which is equivalent to assigning a reference.
Only when $a or $b changes, a copy of the value will be assigned to $a

Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template