我正在使用Symfony的自定义会话处理程序.当我第一次设置会话但刷新页面时,它工作正常.页面将继续加载,max_execution_time在php.ini中定义的30秒后,将显示错误.为了设置自定义保存处理程序,我在棘轮数据库中创建了一个表会话.表中的结构和数据:

现在,页面顶部的脚本看起来像这样初始化自定义保存处理程序:
<?php
ini_set('session.auto_start', false);
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
require dirname(__DIR__) . '/vendor/autoload.php';
$pdo = new \PDO('mysql:host=localhost;dbname=ratchet', 'root', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$storage = new NativeSessionStorage(array(), new PdoSessionHandler($pdo)); // Here when PdoSessionHandler class is initialized again on refreshing it locks the page there
$session = new Session($storage);
$session->start();
$username = $session->get('username');
Run Code Online (Sandbox Code Playgroud)
第153行的PHP脚本引发的错误:

第153行是以下方法中的语句,它从数据库执行和读取会话值.
private function doRead($sessionId)
{
$this->sessionExpired = false;
if (self::LOCK_ADVISORY === $this->lockMode) {
$this->unlockStatements[] = $this->doAdvisoryLock($sessionId);
}
$selectSql = $this->getSelectSql(); …Run Code Online (Sandbox Code Playgroud) 如果我有一个数组,其对象作为索引的值,如:
var a = [];
a[21] = {};
a[90] = {};
a[13] = {};
alert(a.length); // outputs 91
Run Code Online (Sandbox Code Playgroud)
我找到了一个解决方法来获取实际长度:
function getLength(arr) {
return Object.keys(arr).length;
}
var a = [];
a[21] = {};
a[90] = {};
a[13] = {};
alert(getLength(a));
Run Code Online (Sandbox Code Playgroud)
但是,当对象存储在随机索引时,为什么JS会给出不正确的长度?它只是在数组上找到的最大索引加1.与上面的例子一样,90是最大的指数.它只增加1并输出91.示范
我正在关注Ratchet的教程.对于SessionProvider页面,代码如下:
<?php
// Your shell script
use Ratchet\Session\SessionProvider;
use Symfony\Component\HttpFoundation\Session\Storage\Handler;
use Ratchet\App;
$memcache = new Memcache; // Class not found on line 7
$memcache->connect('localhost', 11211);
$session = new SessionProvider(
new MyApp
, new Handler\MemcacheSessionHandler($memcache)
);
$server = new App('localhost');
$server->route('/sessDemo', $session);
$server->run();
Run Code Online (Sandbox Code Playgroud)
当我在以下位置运行脚本时,PHP会抛出致命错误command-line:
在第7行找不到类Memcache
此代码放在bin\chat-server.php中
该类不仅适用于chat-server.php脚本.
我从我的一个朋友那里借了一个android项目,导入之后我得到了一个错误The application was configured for some other audience - appId doesn't match the one in google-services.json.之后,我知道我必须更改java文件的包名并重新连接firebase所以,我做到了.我一直收到错误:
Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.***.***.chitchat'
Run Code Online (Sandbox Code Playgroud)
我在AndroidManifest.xml,build.gradle和google-services.json中拥有相同的包名称.奇怪的是,每个人在做出必要的修改后都解决了问题.我仍然抛出一个错误.这是为什么?