包括不在服务器上工作

I am using

function load($c) {
    if (strpos($c, "Cyclos\\") >= 0) {
        include str_replace("\\", "/", $c) . ".php";
    }
}

spl_autoload_register("load");

It's correctly working on localhost. But after uploading it to the server, it's not working. How do I fix it?

You have two errors here:

  1. strpos() is a case-sensitive function, you should use stripos() instead. The same goes for str_replace(), you should use str_ireplace(). But since you are only replacing a backslash in your code, is doesn't make a difference in this case.

  2. strpos() and stripos() return false if no occurrences are found, and (int) false == 0, so if on occurency if will pass it.

Try this one:

function load($c) {
    if (stripos($c, "Cyclos\\") !== false) {
        include str_replace("\\", "/", $c) . ".php";
    }
}

spl_autoload_register("load");

However, the reason may be different on different filesystems, on localhost you maybe have a case-insensitive filesystem (NTFS for example), and "cyclos.php" is the same as "Cyclos.php", while on **nix systems with EXT* filesystems case variations in file name will play a role.