上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 49 下一页
摘要: Lock.go package lock import ( "context" "crypto/tls" "crypto/x509" "fmt" "go.etcd.io/etcd/clientv3" "io" "io/ioutil" "sync" "time" ) type Mutex struct 阅读全文
posted @ 2024-08-17 16:25 朝阳1 阅读(77) 评论(0) 推荐(0)
摘要: 这种是市面上比较常用的,但是需要数据库存储。或者自己写一套加解密的方法,根据code进行解密,效率更高 直接上代码 <?php function shortUrl($url) { $charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkl 阅读全文
posted @ 2024-08-17 14:52 朝阳1 阅读(169) 评论(0) 推荐(0)
摘要: go语言不像其他语言函数的参数可以设置默认值 以下是参考第三方库的写法 package main import "fmt" type User struct { name string age int id int } // Option 代表可选参数 type Option func(foo *U 阅读全文
posted @ 2024-08-17 10:19 朝阳1 阅读(113) 评论(0) 推荐(0)
摘要: package main import ( "fmt" "github.com/gin-gonic/gin" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheu 阅读全文
posted @ 2024-08-15 15:16 朝阳1 阅读(68) 评论(0) 推荐(0)
摘要: 先看一个代码 $num = 0; try { echo 1 / $num; } catch (Exception $e) { echo $e->getMessage(); } 这时候得catch是无法捕获除数为0得错误 修复 <?php function errorHandler($errno, $ 阅读全文
posted @ 2024-08-12 15:39 朝阳1 阅读(50) 评论(0) 推荐(0)
摘要: 只是为了测试,具体可以参考其他开源软件的写法 原理都是动态创建数据库,导入基础sql,包含管理员信息。然后生成一个install.lock的文件,下次进来判断有这个文件,证明是安装过了 html <!DOCTYPE html> <html lang="en"> <head> <meta charse 阅读全文
posted @ 2024-08-09 17:34 朝阳1 阅读(22) 评论(0) 推荐(0)
摘要: public static function lotto($weight = array()) { $roll = sprintf("%.2f", mt_rand() / mt_getrandmax() * (array_sum($weight))); $_tmpW = 0; $rollnum = 阅读全文
posted @ 2024-08-09 16:42 朝阳1 阅读(35) 评论(0) 推荐(0)
摘要: <?php function array_remove_by_key($data, $key){ if(!array_key_exists($key, $data)){ return $data; } $keys = array_keys($data); $index = array_search( 阅读全文
posted @ 2024-08-09 14:39 朝阳1 阅读(20) 评论(0) 推荐(0)
摘要: test.php <?php if (isset($_POST['upload'])) { var_dump($_FILES); move_uploaded_file($_FILES['upfile']['tmp_name'], 'up_tmp/'.time().'.dat'); exit; } ? 阅读全文
posted @ 2024-08-09 14:16 朝阳1 阅读(36) 评论(0) 推荐(0)
摘要: <?PHP //图像处理类 class Image { private $file; //图片地址 private $width; //图片长度 private $height; //图片长度 private $type; //图片类型 private $img; //原图的资源句柄 private 阅读全文
posted @ 2024-08-09 14:11 朝阳1 阅读(32) 评论(0) 推荐(0)
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 49 下一页