解析错误网站

时间:2014-10-12 16:36:10

标签: php parse-error

我的网站上有一个解析错误,我该如何解决?

错误:

  

解析错误:语法错误,意外' function__construct' (T_STRING),在第7行的/home/retropla/domains/triangledevelopment.nl/public_html/classes/class.user.php中期待变量(T_VARIABLE)

Class.users.php:

<?php

include('class.password.php');

class User extends Password{

private $db;

function__construct($db){
    parent::__construct();

    $this->_db = $db;
}

public function is_logged_in(){
    if(isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true){
        return true;
    }       
}

private function get_user_hash($username){  

    try {

        $stmt = $this->_db->prepare('SELECT password FROM blog_members WHERE username = :username');
        $stmt->execute(array('username' => $username));

        $row = $stmt->fetch();
        return $row['password'];

    } catch(PDOException $e) {
        echo '<p class="error">'.$e->getMessage().'</p>';
    }
}


public function login($username,$password){ 

    $hashed = $this->get_user_hash($username);

    if($this->password_verify($password,$hashed) == 1){

        $_SESSION['loggedin'] = true;
        return true;
    }       
}


public function logout(){
    session_destroy();
}

}


?>

我正在教程上创建一个网站并显示此错误。

1 个答案:

答案 0 :(得分:2)

function__construct($db){

应该是:

public function __construct($db){
  • function__construct之间需要有空格。