【发布时间】:2016-06-11 13:48:34
【问题描述】:
我有这个错误:
在中未找到接口“SessionHandlerInterface” /membri/francescorizzi/php_SessionMgr/MySessionHandler.php 在第 3 行
这是我的界面代码(取自 php.net 作为起点):
<?php
class MySessionHandler implements SessionHandlerInterface{
private $savePath;
public function open($savePath, $sessionName)
{
$this->savePath = $savePath;
if (!is_dir($this->savePath)) {
mkdir($this->savePath, 0777);
}
return true;
}
public function close()
{
return true;
}
public function read($id)
{
return (string)@file_get_contents("$this->savePath/sess_$id");
}
public function write($id, $data)
{
return file_put_contents("$this->savePath/sess_$id", $data) === false ? false : true;
}
public function destroy($id)
{
$file = "$this->savePath/sess_$id";
if (file_exists($file)) {
unlink($file);
}
return true;
}
public function gc($maxlifetime)
{
foreach (glob("$this->savePath/sess_*") as $file) {
if (filemtime($file) + $maxlifetime < time() && file_exists($file)) {
unlink($file);
}
}
return true;
}
}
我也尝试过使用implements \SessionHandlerInterface 或use SessionHandlerInterface,但这不起作用。
如何解决?
谢谢!
编辑:
我注意到,如果我通过 URL 加载所有代码:
www.site.org/main.php?...
它有效,但如果我使用这个:
www.site.org/index.html?...
出现错误。
我的 index.html 页面包含 main.php 代码。 哪里出错了?
INDEX.HTML 代码:
<html>
<body bgcolor="#000000">
<body text="grey">
<?php include('Main.php') ?>
</body>
</html>
.htaccess 文件:
# # av:php5-engine
AddHandler av-php56 .php
AddType application/x-httpd-php .htm .html
RewriteRule ^index.html$ main.php
【问题讨论】: