自执行函数模拟块级作用域

Original 2019-05-09 15:21:40 112
abstract:<?php  function func(){ $city = '武当山'; $text=function()use($city){ $userName = '张三丰';           
<?php 
function func(){
	$city = '武当山';
	$text=function()use($city){
			$userName = '张三丰';
            return  '我叫' . $userName.'<br>'.'我住在'. $city;
			// return $b;
		};
	return $text();
}
echo func();


Correcting teacher:查无此人Correction time:2019-05-10 13:56:43
Teacher's summary:完成的不错。php的作用域还是很好理解的。继续加油。

Release Notes

Popular Entries