<?php
// 编写自己的http服务器
/**
 * 第1个参数, 0.0.0.0 表示监听本机所有的网址地址
 * 第2参数,6060 表示监听端口号  当前建议1-1024之间是系统保留不要去用
 */
$http = new swoole_http_server('0.0.0.0', 6060);
// 设置
$http->set([
    // 工作的进程数量
    'worker_num'  => 2,
    // 一个进程请求的最大次数
    'max_request' => 1000
]);
// 相关事件的监听
// 开始事件
$http->on('start', function (swoole_server $server) {
    echo "服务启动了!\n";
});
// 处理请求事件
/**
 * $request 请求对象  服务器请求得到客户发过来的数据对象
 * $response 响应对象 服务器向客户发送数据所用的对象
 */
$http->on('request', function (swoole_http_request $request, swoole_http_response $response) {
    // 加上头信息
    $response->header('Content-Type', 'text/html;charset=utf-8');
    $response->end('你好世界');
});
// 启动服务
$http->start();编写http服务器
相关推荐
- 
                            生成图片from PIL import Image, ImageColor, ImageDraw, ImageFont, ImageFilterdef create_image_with_text(size, color, text, font_path, font_size, text_color, shadow_color, output_path): """ Create a new image of specified size and color with centered text that has a border and shadow. :param size: A tuple con 查看详情
- 
                            获取指定目录下的所有图片信息1 获取指定目录下的所有图片信息// 获取指定目录下的所有图片信息 public function getImagesInfo($directory) { $images = []; // 创建递归目录迭代器 $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY ); // 遍历目录中的每个文件 foreach ( 查看详情
- 
                            Thinkphp各版本的PHP要求ThinkPHP 8.0:运行环境要求PHP8.0+,兼容PHP8.3ThinkPHP 6.1:运行环境要求PHP7.2+,兼容PHP8.1ThinkPHP 6.0:运行环境要求PHP7.2+,兼容PHP8.1ThinkPHP 5.1:运行环境要求PHP5.6+,兼容PHP8.0ThinkPHP 5.0:运行环境要求PHP5.4+,兼容PHP7.3 查看详情
 智享笔记
								    智享笔记								 
                             
                             
                             
                            