[英]SessionHandlerInterface not found
I have this error: 我有这个错误:
Interface 'SessionHandlerInterface' not found in /membri/francescorizzi/php_SessionMgr/MySessionHandler.php on line 3
在第3行的/membri/francescorizzi/php_SessionMgr/MySessionHandler.php中找不到接口“ SessionHandlerInterface”
here is my interface code (taken from php.net as a start point): 这是我的界面代码(取自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;
}
}
I tried also using implements \\SessionHandlerInterface
or use SessionHandlerInterface
but this didn't work. 我也尝试使用
implements \\SessionHandlerInterface
或use SessionHandlerInterface
但这没有用。
How to solve this? 如何解决呢?
Thanks! 谢谢!
EDIT: 编辑:
I noticed that if i load all my code throught URL: 我注意到如果我通过URL加载所有代码:
www.site.org/main.php?...
www.site.org/main.php?...
it works, but if i use this: 它有效,但是如果我用这个:
www.site.org/index.html?...
www.site.org/index.html?...
the error comes up. 错误出现。
My index.html page includes the main.php code. 我的index.html页面包含main.php代码。 Where is the error?
错误在哪里?
INDEX.HTML CODE: INDEX.HTML代码:
<html>
<body bgcolor="#000000">
<body text="grey">
<?php include('Main.php') ?>
</body>
</html>
.htaccess file: .htaccess文件:
# # av:php5-engine
AddHandler av-php56 .php
AddType application/x-httpd-php .htm .html
RewriteRule ^index.html$ main.php
Is it possible that you are using an older PHP version? 您是否可能使用的是较旧的PHP版本? As stated in the official PHP documentation, the SessionHandlerInterface is only available starting with PHP 5.4.0
如官方PHP文档所述,SessionHandlerInterface仅从PHP 5.4.0开始可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.