致命错误:无法实例化不存在的类:simplexmlelement

Chr*_*ris 2 php

我正在使用这个PHP脚本

$error = false;
if(isset($_POST['login'])){
    $username = preg_replace('/[^A-Za-z]/', '', $_POST['username']);
    $password = md5($_POST['password']);
    if(file_exists('users/' .$username . '.xml')){
        $xml = new SimpleXMLElement('users/' .$username . '.xml', 0, true);
        if($password == $xml->password){
            session_start();
            $_SESSION['username'] = $username;
            header('Location: agis-employees.html');
            die;
        }
    }
    $error = true;
}
Run Code Online (Sandbox Code Playgroud)

我最终得到了这个错误

致命错误:无法实例化不存在的类:第7行/home/virtual/site250/fst/var/www/html/employeeportal/index.php中的simplexmlelement

kar*_*m79 5

这很可能意味着PHP安装中未启用/存在SimpleXML扩展.您可以通过执行phpinfo()并查找"SimpleXML" 来验证这一点.看到:

http://www.php.net/manual/en/simplexml.installation.php http://www.php.net/manual/en/book.simplexml.php