繁体   English   中英

找不到php类,但包含了

[英]php class not found but included

我的代码有问题。 我为所有包含文件创建了一个全局文件。

define('A', 'app/');
define('C', 'config/');
define('S', 'classes/');
define('P', 'pages/');
define('J', 'ajax/');
define('T', 'post/');
define('B', realpath(dirname(__FILE__) ) . '/');

/*

Invoegen van de classes. Nieuwe classes gelieven bij te schrijven. De Letter voor de map is de link naar het bestand, zoals bij de 
eerdere voorbeelden weergegeven.

*/



require_once(B . A . C . 'config.inc.php');
require_once(B . A . S . 'class.functions.php');
require_once(B . A . S . 'functions.php');
require_once(B . A . S . 'class.database.php');
require_once(B . A . S . 'class.users.php');

我用ajax发布到postlogin.php

$.ajax({
    url: 'app/classes/ajax/post/postlogin.php',
    type: "POST",
    dataType: "json",
    data: {method: method, email: email, password: password},
    //contentType: "application/json; charset=utf-8",
    success: function (returnmsg) {
        var bla = returnmsg.msg;
        alert(bla);
    },
    error: function (xhr, status, error) {
        alert("error " +xhr.responseText);
    }
});

但是当我发布到postlogin.php时,他找不到我的课程class.users.php

当我在索引中调用此类时,它将起作用。

postlogin.php:

<?php

return Users::AdminLogin();

?>

希望有人可以帮助我..

PS对不起,我的英语不好,我希望有人能理解。

您需要在postlogin.php中包含“全局文件”。 PHP无法知道此文件的存在,您的AJAX请求将直接发送到postlogin.php。

您也可以只包含class.users.php文件。

暂无
暂无

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

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