Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
檀越@新空间
Coding Tree
提交
9c3341dc
C
Coding Tree
项目概览
檀越@新空间
/
Coding Tree
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coding Tree
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9c3341dc
编写于
4月 19, 2022
作者:
彭世瑜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
efa0f95f
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
84 addition
and
5 deletion
+84
-5
blog/php-basic/function.md
blog/php-basic/function.md
+1
-1
blog/php-basic/include.md
blog/php-basic/include.md
+2
-2
blog/php-basic/index.md
blog/php-basic/index.md
+2
-2
blog/websocket/index.html
blog/websocket/index.html
+39
-0
blog/websocket/package.json
blog/websocket/package.json
+19
-0
blog/websocket/server.js
blog/websocket/server.js
+21
-0
未找到文件。
blog/php-basic/function.md
浏览文件 @
9c3341dc
...
@@ -182,7 +182,7 @@ echo $hello;
...
@@ -182,7 +182,7 @@ echo $hello;
1、作用域分类:
1、作用域分类:
-
超全局变量:系统定义的变量(预定义变量:
$
\_
POST
)
-
超全局变量:系统定义的变量(预定义变量:
`$_POST`
)
-
没有访问限制
-
没有访问限制
-
全局变量:函数外部定义的变量
-
全局变量:函数外部定义的变量
-
只允许在全局空间中使用,理论上函数内部不可用
-
只允许在全局空间中使用,理论上函数内部不可用
...
...
blog/php-basic/include.md
浏览文件 @
9c3341dc
# PHP 文件包含
# PHP 文件包含
include/require
在一个 PHP 脚本中,去将另一个文件包含进来
在一个 PHP 脚本中,去将另一个文件包含进来
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
语法
语法
```
```
php
include
'文件路径'
;
include
'文件路径'
;
include
(
'文件路径'
);
include
(
'文件路径'
);
```
```
...
...
blog/php-basic/index.md
浏览文件 @
9c3341dc
...
@@ -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
)
...
...
blog/websocket/index.html
0 → 100644
浏览文件 @
9c3341dc
<!-- 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
blog/websocket/package.json
0 → 100644
浏览文件 @
9c3341dc
{
"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"
}
}
blog/websocket/server.js
0 → 100644
浏览文件 @
9c3341dc
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录