我正在尝试使用PHP和本机zmq实现推送集成.我已成功发送我的消息发送到服务器,但我的问题是我无法使用js Websocket()将消息推送到浏览器.我说WebSocket连接到'ws://127.0.0.1:8080 /'失败:WebSocket握手期间出错:状态行无效
这是我的客户代码:
<?php
try {
function send($data) {
$context = new ZMQContext();
$push = new ZMQSocket($context, ZMQ::SOCKET_PUSH);
$push->connect("tcp://localhost:5555");
$push->send($data);
}
if(isset($_POST["username"])) {
$envelope = array(
"from" => "client",
"to" => "owner",
"msg" => $_POST["username"]
);
send(json_encode($envelope)); # send the data to server
}
}
catch( Exception $e ) {
echo $e->getMessage();
}
?>
Run Code Online (Sandbox Code Playgroud)
客户
这是我的服务器:
$context = new ZMQContext();
$pull = new ZMQSocket($context, ZMQ::SOCKET_PULL);
$pull->bind("tcp://*:5555"); #this will be my pull socket from client
$push = new ZMQSocket($context, …Run Code Online (Sandbox Code Playgroud) 刚刚开始欣赏正则表达式,我正在regexone.com上练习 我的问题是关于kleene"*"的解释.我想出了一个自己的答案"
[a-c]*
Run Code Online (Sandbox Code Playgroud)
但解决方案是:
aa+b*c+ or a*b*c*
Run Code Online (Sandbox Code Playgroud)
与两者的行为方面有什么不同吗?特别是如果我使用它与JavaScript?
对不起,我的英语不好.
嗨我试图访问所选元素的子节点,但浏览器告诉我该对象没有foreach函数.我应该怎样做才能访问子元素.我不想使用jquery而是想使用native,用于实验目的.
这是我的代码:
var el = document.querySelector('ol');
el.children.forEach(function(childEl) {
console.log(childEl);
})Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ol contenteditable oninput="">
<li>press enter</li>
</ol>
</body>
</html>Run Code Online (Sandbox Code Playgroud)