Home > Backend Development > PHP Tutorial > 大家帮忙分析下这段函数输出?该如何解决

大家帮忙分析下这段函数输出?该如何解决

WBOY
Release: 2016-06-13 13:53:32
Original
799 people have browsed it

大家帮忙分析下这段函数输出?
大家帮忙分析下:输出结果?
function a($n)
{
  return ( b($n) * $n );
}
function b(&$n){
  ++$n;
}

echo a(5);
?>


------解决方案--------------------
如果加上return 
那么a(5)实际上就相当于 b(5)*$n,执行完b(5)后返回值是6,也就是b(5) =6.且$n 加1变为6.所以最后的结果是
6*6=36.

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