Blogger Information
Blog 19
fans 0
comment 0
visits 10107
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
函数参数返回值及变量作用域的理解
bloght5386
Original
455 people have browsed it

1. 总结函数的返回值,参数?

  1. 函数的返回值return 可以返回基本数据类型,也可以返回对象、数组等复合类型。return 后面的语句不再执行。
  2. 参数分为实参和形参,被调用函数的参数是形参可以是基本数据类型,也可以是对象、数组等复合类型,调用参数是实参,必须有确定的值,可以是基本数据类型和复合类型。

2. 实例演绎你对课上匿名函数以及变量作用域问题的理解?

  1. $product = 'IPHONE';
  2. $price = 5000;
  3. //闭包
  4. 函数体内变量不能访问函数外的变量,如果需要使用需要use函数来调用
  5. $closure1 = function() use ($product,$price)
  6. {
  7. return sprintf('今日主推产品是%s, 商品价格是%d',$product,$price);
  8. };
  9. echo $closure1();
Correcting teacher:灭绝师太灭绝师太

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post