我需要从php脚本发布消息,我可以发布单个消息.但现在我需要在循环中发布不同的消息,找不到正确的方法如何做,这是我尝试的:
$counter = 0;
$closure = function (\Thruway\ClientSession $session) use ($connection, &$counter) {
//$counter will be always 5
$session->publish('com.example.hello', ['Hello, world from PHP!!! '.$counter], [], ["acknowledge" => true])->then(
function () use ($connection) {
$connection->close(); //You must close the connection or this will hang
echo "Publish Acknowledged!\n";
},
function ($error) {
// publish failed
echo "Publish Error {$error}\n";
}
);
};
while($counter<5){
$connection->on('open', $closure);
$counter++;
}
$connection->open();
Run Code Online (Sandbox Code Playgroud)
在这里,我想向订阅者发布$ counter值,但值总是5,1.我有一种方法可以在循环之前打开连接然后在循环中发布消息2.如何从$ session-> publish()访问循环?
谢谢!
我需要禁止在输入字段中写入全角日语字符,半角可以,除全角之外的任何其他符号都可以。
在这里https://gist.github.com/terrancesnyder/1345094 我找到了全角片假名(zenkaku ??)的正则表达式就够了吗?目前我的代码看起来像这样
if ( /[?-?]/.test("??") ) {
console.log('full width');
}else{
console.log('not full width');
}
Run Code Online (Sandbox Code Playgroud)
我不熟悉日语所以我不知道我还需要检查什么,我的意思是他们有片假名、平假名等等,这就是为什么我不确定我的剧本是否足够好,请告诉我你怎么看
我有mysql用户定义的函数
DELIMITER $$
CREATE FUNCTION `myfunc`(`str` TEXT) RETURNS TEXT CHARSET utf8
NO SQL
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
RETURN str;
END$$
DELIMITER ;
Run Code Online (Sandbox Code Playgroud)
它只是返回传递的参数而不进行任何更改
我的问题是,如果我通过一些俄语或希腊字母,那么我只会返回?????? 作为回应
SELECT myfunc('??????????');
Run Code Online (Sandbox Code Playgroud)
将返回 ??????????
如果我调用 SELECT myfunc('sdfasfsdf'); 结果我得到了 sdfasfsdf
找不到问题在哪里,有什么想法吗?