【发布时间】:2013-12-15 23:17:21
【问题描述】:
我是 php 新手,我正在尝试为我的网站创建一个会员系统。我似乎在第 9 行 ("public function__construct(){") 上遇到错误,说“语法错误,意外 T_STRING,期待 T_VARIABLE”。对于我为什么会收到此错误,我将不胜感激。谢谢。
我的代码:
<?php
include_once('connection.php')
class User {
private $db;
public function__construct(){
$this->db = new connection ();
$this->db = $this->db->dbConnect();
}
public function Login($name, $pass){
if (!empty($name) && !empty($pass) ) {
$st = $this->db->prepare("select * from users where name=? and pass=?");
$st->bindParam(1, $name);
$st->bindParam(2, $pass);
$st->execute();
if ($st->rowCount() == 1) {
echo "user verified access granted";
}else{
echo "Incorrect username or password";
}
}else{
echo "Please enter username and password";
}
}
}
?>
【问题讨论】:
-
public function__construct(){函数后缺少空格 -
非常感谢,成功了!
标签: php