You're experiencing that because in linux the filesystem paths are case sensitive.
PHP can not __autoload classes
-
15-10-2022 - |
문제
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.
해결책
다른 팁
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');
제휴하지 않습니다 StackOverflow