2014-09-18 48 views

回答

2

您只需包括他们(require是这个关键字):

<?php 
    require Create.php; 
    require Insert.php; 

    // depending on what the files contain, you can now execute their 
    // functions, instantiate their classes, or in case they produce 
    // direct output, it will be visible now. 
?> 
+1

顺便说一句,关于不同的方式包括一个文件:http://www.paulund .co.uk /差异-php-include-and-require – lxg 2014-09-18 17:20:56

+0

在Create.php和Insert.php文件中,我已经包含了其他的php文件。那么,对我而言哪个更好?包括或要求? – programmer 2014-09-18 17:28:17

+0

简而言之:永远不要使用'include'或'include_once' - 它们从来没有意义。实际上,甚至不要使用'require',我只用了,因为我不知道是否需要多次加载这些文件。最好的做法是将代码封装在函数和类中,然后使用'require_once'将它们精确地包含*一次*。 – lxg 2014-09-18 17:36:25