【问题标题】:Parse error site [closed]解析错误站点[关闭]
【发布时间】:2014-10-12 16:36:09
【问题描述】:

我的网站出现解析错误,我该如何解决?

错误:

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

类.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();
}

}


?>

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

【问题讨论】:

    标签: php parse-error


    【解决方案1】:
    function__construct($db){
    

    应该是:

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

    【讨论】:

    • 是的,这样就行了。
    猜你喜欢
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    • 2015-03-04
    • 2011-09-24
    • 2016-05-22
    • 2010-11-18
    • 2013-02-08
    • 2014-04-21
    相关资源
    最近更新 更多