Home > Backend Development > PHP Tutorial > 另一路PHP面试题

另一路PHP面试题

WBOY
Release: 2016-06-13 12:17:36
Original
1213 people have browsed it

另一道PHP面试题



本题来自兄弟连云课堂。
写出运行结果:

 function myfunc($argument){

              echo $argunment + 10;

       }

       $variable= 10;

       echo“myfunc($variable)=”.myfunc($variable);










答案:1、   echo“myfunc($variable)=”.myfunc($variable);  这句会怎样执行??

会先执行后面部分"myfunc($variable);" 再执行echo,所以答案至少是  20myfunc($variable)= 。20就是 myfunc($variable); 执行结果。

2、echo“myfunc($variable)=”. 会怎样解析? 双引号里的变量会被执行,而函数不会被执行。所以等于:myfunc(10)=。

所以,答案至少是 
20myfunc(10)= 。

但仔细看, function myfunc($argument){

              echo $argunment + 10;

       }

函数传进变量是 $argument,下面却是$argunment,这是很迷惑人得。所以,这个函数里 $argunment 不会 被打印。

本地最终正确答案是:10myfunc(10)= 


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