A function inside an if structure

前端 未结 5 606
执笔经年
执笔经年 2020-12-31 02:42

can I put a function in PHP inside a if structure? like this:



        
5条回答
  •  温柔的废话
    2020-12-31 03:15

    Basically yes, according to the manual:

    Any valid PHP code may appear inside a function, even other functions and class definitions.

    Personally I haven't had a situation in which I'd actually do such a thing. Most of the time it would be easier to group your functions on a place where it actually can be found! ;-)

提交回复
热议问题