提交 9c3341dc 编写于 作者: 彭世瑜's avatar 彭世瑜

fix

上级 efa0f95f
...@@ -182,7 +182,7 @@ echo $hello; ...@@ -182,7 +182,7 @@ echo $hello;
1、作用域分类: 1、作用域分类:
- 超全局变量:系统定义的变量(预定义变量:$\_POST - 超全局变量:系统定义的变量(预定义变量:`$_POST`
- 没有访问限制 - 没有访问限制
- 全局变量:函数外部定义的变量 - 全局变量:函数外部定义的变量
- 只允许在全局空间中使用,理论上函数内部不可用 - 只允许在全局空间中使用,理论上函数内部不可用
......
# PHP 文件包含 # PHP 文件包含include/require
在一个 PHP 脚本中,去将另一个文件包含进来 在一个 PHP 脚本中,去将另一个文件包含进来
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
语法 语法
``` ```php
include '文件路径'; include '文件路径';
include('文件路径'); include('文件路径');
``` ```
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
7. [PHP 常用的系统函数](blog/php-basic/system.md) 7. [PHP 常用的系统函数](blog/php-basic/system.md)
[PHP 文件包含](blog/php-basic/include.md) 8. [PHP 文件包含include/require](blog/php-basic/include.md)
[PHP 函数 function](blog/php-basic/function.md) 9. [PHP 函数 function](blog/php-basic/function.md)
[PHP 错误处理 error](blog/php-basic/error.md) [PHP 错误处理 error](blog/php-basic/error.md)
......
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>WebSocket Demo</title>
</head>
<body>
<input type="text">
<button>发送</button>
<div id="content"></div>
<script src="https://cdn.bootcdn.net/ajax/libs/socket.io/4.4.1/socket.io.min.js"></script>
<script>
var socket = io('http://localhost:8080');
var content = document.getElementById('content');
var input = document.querySelector('input');
var button = document.querySelector('button');
// 发送消息
button.addEventListener('click', function () {
socket.emit('message', input.value);
});
// 接收服务器消息
socket.on('message', function (data) {
content.innerHTML += data + '<br>';
});
</script>
</body>
</html>
\ No newline at end of file
{
"name": "websocket",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"dayjs": "^1.11.1",
"express": "^4.17.3",
"nodejs-websocket": "^1.7.2",
"socket.io": "^4.4.1"
}
}
const { Server } = require('socket.io');
const { createServer } = require('http');
const httpServer = createServer();
// 处理跨域
const io = new Server(httpServer, {
cors: {
origin: '*',
},
});
io.on('connection', (socket) => {
// 接收数据
socket.on('message', (data) => {
// 发送数据
socket.emit('message', data);
});
});
httpServer.listen(8080);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册