我的网站上有一个解析错误,我该如何解决?
错误:
解析错误:语法错误,意外' 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();
}
}
?>
我正在教程上创建一个网站并显示此错误。
答案 0 :(得分:2)
function__construct($db){
应该是:
public function __construct($db){
function
和__construct
之间需要有空格。