PHP引述陷阱
Jun 13, 2016 am 10:47 AM
amp
echo
nbsp
php
PHP引用陷阱
1. $a = '333';
$c = &$a;
$d = '888';
$c = &$d;
echo $c;
echo $a;
2. $a = '333';
$c = &$a;
$d = '888';
$c = $d;
echo $c;
echo $a;
其中第四行$c = $d和$c = &$d,导致的结果完全不一样.
$c = $d,因为$c是$a的一个引用,所以$c和$a的值都会变成888,
但是$c = &$d,是$c变成了$d的引用了,和$a已经没有关系了,所以此时$a的值还是333.
注意,引用只是一个别名而已,并不是指针.
其实类似于Unix的硬连接.
http://www.php.net/manual/zh/language.references.whatare.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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
