當更新我的PHP版本5.4(XAMPP 1.8.0)我看到致命錯誤:PHP:致命錯誤:不能重新聲明堂課
Fatal error: Cannot redeclare class Session in C:\xampp\htdocs\vs\classes\session.class.php on line 5
這是問題的更新版本PHP
的關係嗎?
session.class.php:
<?php
defined('_VALID') or die('Restricted Access!');
class Session
{ // <-- This Is Line 5
private static $_sess_db;
public static function open() {
global $config;
if (self::$_sess_db = mysql_connect($config['db_host'], $config['db_user'], $config['db_pass'])) {
return mysql_select_db($config['db_name'], self::$_sess_db);
}
return false;
}
public static function close() {
return mysql_close(self::$_sess_db);
}
public static function read($session_id) {
$sql = sprintf("SELECT `session_data` FROM `sessions` WHERE `session_id` = '%s'", mysql_real_escape_string($session_id));
if ($result = mysql_query($sql, self::$_sess_db)) {
if (mysql_num_rows($result)) {
$record = mysql_fetch_assoc($result);
return $record['session_data'];
}
}
return '';
}
public static function write($session_id, $session_data)
{
$sql = sprintf("REPLACE INTO `sessions` VALUES('%s', '%s', '%s')", mysql_real_escape_string($session_id),
mysql_real_escape_string(time()), mysql_real_escape_string($session_data));
return mysql_query($sql, self::$_sess_db);
}
public static function destroy($session_id)
{
$sql = sprintf("DELETE FROM `sessions` WHERE `session` = '%s'", $session_id);
return mysql_query($sql, self::$_sess_db);
}
public static function gc($max) {
$sql = sprintf("DELETE FROM `sessions` WHERE `session_expires` < '%s'", mysql_real_escape_string(time() - $max));
return mysql_query($sql, self::$_sess_db);
}
}
如何頁是叫什麼名字?這聽起來像你有一個雙重的'include'或'require'的地方。嘗試使用'include_once'或'require_once'來代替 – cegfault 2012-08-02 19:25:47
[問很多次,之前很多次](http://stackoverflow.com/search?q=%5Bphp%5D+Fatal+error%3A+Cannot+redeclare+class) – 2012-08-02 19:32:49