繁体   English   中英

我的 spl_autoload_register() function 不适用于 cpanel 但在 localhost 中工作正常

[英]My spl_autoload_register() function is not working for cpanel but working fine in localhost

我的spl_autoload_register() function 不适用于 cpanel,但在 localhost 中工作正常。

这是input.php文件中输入 class 的代码:-

class Input {
public static function exists($type = 'post') {
    switch($type) {
        case 'post':
            return return $_POST[$item];
            break;
        default:
            return false;
        break;
    }
}}

通过下面的这个init.php文件,我试图访问我的input.php文件。

spl_autoload_register(function($class) {
   require_once $class . '.php';
});

现在我正在尝试访问我的表单中的init.php文件form.php文件,我无法查看该页面,它在 cpanel 中上传这些文件时显示空白屏幕,但在我的本地主机中它没问题。

 require_once 'init.php';

 if(Input::exists()) {
   <form action="" method="post">
        <label for='name'>name</label>
        <input type="text" name="name" id="name">
    <input type="submit" value="Login">
   </form>
   }else{
       echo "no form";
   }

php spl_autoload_register() function 通常在 cpanel 上有冲突,最好在 init 文件中手动要求所有类。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM