2010-07-27 50 views
0

是否有可能讓我的類文件已經包含在文件夾的所有文件中?已包含類

回答

1

還有auto_prepend_file配置選項
所以,你可以添加一個。 htaccess文件(如果你運行PHP作爲Apache模塊),該文件夾與以下行:

php_value auto_prepend_file /path/to/that/file 
4

,還可以自動在前面加上使用auto_prepend_file文件 - 設置php.ini中的路徑,httpd.conf中或.htaccess文件:

Specifies the name of a file that is automatically parsed before the main file. The file is included as if it was called with the require() function, so include_path is used. 
0

除了使用已經提到autoloading of classes你也可以指定一個.htaccess文件與auto_prepend_file的文件

php_value auto_prepend_file foo.php 

有了這個,只要在該目錄中的PHP文件或子目錄請求foo.php加載文件:之前被加載。