Home > Backend Development > PHP Tutorial > 一道关于php变量引用的面试题_PHP

一道关于php变量引用的面试题_PHP

WBOY
Release: 2016-06-01 12:18:07
Original
895 people have browsed it

php面试题题目如下:
复制代码 代码如下:
$a = 1;
$x =&$a;
$b=$a++;
?>

问:
$b和$x的值分别是什么?

php面试题的答案如下:
$b = 1;
$x = 2;

明白了吗? 没明白,再好好想想。 当一个变量等于另一个变量的引用的时候,这时任何一方改变了其值,另一方看到的这个值也会变化的。前加本次就表现出来,而后加下一次才会表现出来。

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