Require multiple files

后端 未结 3 674
别跟我提以往
别跟我提以往 2021-01-02 10:20

I am building a PHP application that uses a select menu to build email templates. The templates are broken into reusable parts (each is a separate html file). Is there an

3条回答
  •  渐次进展
    2021-01-02 10:41

    Well, you could turn it into a function:

    function require_multi($files) {
        $files = func_get_args();
        foreach($files as $file)
            require_once($file);
    }
    

    Use like this:

    require_multi("one.php", "two.php", ..);
    

    However, if you're including classes, a better solution would be to use autoloading.

提交回复
热议问题