PHP - defining classes inside a function

后端 未结 5 1145
清歌不尽
清歌不尽 2021-01-12 00:04

Is this a bad practice?

like:

function boo(){
  require_once(\"class.moo.php\");
}
...

?

5条回答
  •  死守一世寂寞
    2021-01-12 00:28

    This is generally a bad practice and should be avoided. You should probably consider using an autoloader instead.

提交回复
热议问题