Should require_once “some file.php” ; appear anywhere but the top of the file?

前端 未结 5 872
时光取名叫无心
时光取名叫无心 2021-01-05 23:32

Is the following example appropriate for PHP\'s require_once construct?

function foo( $param )
{
    require_once \"my_file.php\" ;
    //
    // do somethin         


        
5条回答
  •  难免孤独
    2021-01-06 00:16

    If you don't want to load a file unless it's needed, look into autoloading - on newer PHP via spl_autoload_register().

提交回复
热议问题