I have index.php where i keep my __autoload() function that loads classes from a lib folder.
function __autoload($class) {
if(file_exists(LIBS . $class .".php")){
require LIBS . $class .".php";
}
}
I have a Dashboard class
class Dashboard extends Controller {
public function __construct(){
Auth::handleLogin();
}
}
Using sudo apt-get install php5 and apache2 on Ubuntu 12.04 i am not able to autoload that Auth, what could possibly go wrong? It works on my other computer which uses a Bitnami XAMPP server.
This is the error i get:
Fatal error: Class 'Auth' not found in /var/www/app/controllers/dashboard.php on line 6
Where the Auth::handleLogin(); is being called.
您遇到这种情况,因为在linux中,文件系统路径区分大小写。
i have linux mint 16 and i use this with namespaces when i do object declaration and it is work perfect
spl_autoload_register(function ($class) {
$class = str_replace("\\", "/", $class);
include $class . '.php';
});
in index file
require_once 'autoload.php';
$db = new DBWork\DBWork('localhost', 'northwind', 'root', '123');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.