类代码:
<?php
class db{
var $db = array(
host => ““,
username => ““,
password => ““,
selected => ““
function conn(){
@ $db = new mysqli(
$this->db[“host“],
$this->db[“username“],
$this->db[“password“],
$this->db[“selected“]
if (mysqli_connect_errno())
printf(“Connect failed: %s\n“,mysqli_connect_error());
exit;
function dbinsert($sql){
$resule = $db->query($sql);
if (!$resule){
echo ’Can\’t insert data to database’;
exit;
function dbupdata($sql){
$resule = $db->query($sql);
if (!$resule){
echo ’Can\’t updata data to database’;
exit;
function dbdelete($sql){
$resule = $db->query($sql);
if (!$resule){
echo ’Can\’t delete data from database’;
exit;
function dbselect($sql){
$resule = $db->query($sql);
if (!$resule){
echo ’Can\’t select data on database’;
exit;
?>
调用代码:
<?php
include(“inc/dbconn.php“);
$dbconn = new db;
$dbconn->db = array(
host => ““,
username => “XXXX“,
password => “XXX“,
selected => “XXX“
?>
错误信息:
Parse error: syntax error, unexpected T_FUNCTION, expecting ’,’ or ’;’ in i:\
PS:经过边调试已经解决一些其他基本语法错误,这个错误报在FUNCTION上,我刚刚接触类,技术上不是很成熟,有时间的朋友麻烦帮指点下,或者贴点例子参考下,谢谢.