为了账号安全,请及时绑定邮箱和手机立即绑定

什么是PHP嵌套函数?

什么是PHP嵌套函数?

慕的地10843 2019-11-29 14:53:58
在JavaScript中,嵌套函数非常有用:闭包,私有方法以及您拥有的东西。什么是嵌套PHP函数?有人使用它们吗?这是我做的小调查<?phpfunction outer( $msg ) {    function inner( $msg ) {        echo 'inner: '.$msg.' ';    }    echo 'outer: '.$msg.' ';    inner( $msg );}inner( 'test1' );  // Fatal error:  Call to undefined function inner()outer( 'test2' );  // outer: test2 inner: test2inner( 'test3' );  // inner: test3outer( 'test4' );  // Fatal error:  Cannot redeclare inner()
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 535 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信