随笔分类 - php
摘要:<?php /** * 高性能布隆过滤器(使用扩展或位运算优化) */ class BloomFilter { /** @var int 比特位长度 */ protected $size; /** @var int 哈希函数个数 */ protected $hashCount; /** @var s
阅读全文
摘要:<?php // 支付列表数组 $paymentList = [ ['name' => '支付宝', 'info' => '支持多种支付场景', 'weight' => 3], ['name' => '微信支付', 'info' => '便捷的移动支付', 'weight' => 2], ['nam
阅读全文
摘要:地址 https://github.com/PHPGangsta/GoogleAuthenticator 示例 index.php <?php require_once 'PHPGangsta/GoogleAuthenticator.php'; $ga = new PHPGangsta_Google
阅读全文
摘要:php版本必须>=8.0 文档地址 https://docs.rs/ext-php-rs/0.12.0/ext_php_rs/index.html 创建lib项目 cargo new ext_php_rs --lib cd ext_php_rs 编辑toml [dependencies] ext-p
阅读全文
摘要:PHP 在转换为布尔值时,以下值被认为是 false: 布尔值 false 本身 整型值 0(零) 浮点型值 0.0(零) 空字符串 "",以及字符串 "0" 不包括任何元素的数组 原子类型 NULL(包括尚未赋值的变量) 所有其他值都被认为是 true,包括非空字符串,即使它们包含的是 "fals
阅读全文
摘要:文件 strace -e trace=file php 脚本.php 进程id strace -f -s 6555 -p 进程id 查看进程树 pstree -p 进程id pstree -p | grep php
阅读全文
摘要:hyperf框架的orm其实就是基于laravel改造的。会laravel就会hyperf,只不过目前为止hyperf的文档都没有填充相关的。 生成迁移文件,这点文档有,具体可以参考文档 https://hyperf.wiki/3.1/#/zh-cn/db/migration php bin/hyp
阅读全文
摘要:官网对函数的解释 https://www.php.net/array_reduce <?php interface Middleware { public static function handle(Closure $next); } class Middleware1 implements Mi
阅读全文
摘要:使用$argv or $argc参数接收 <?php echo "接收到{$argc}个参数"; print_r($argv); php test.php 接收到1个参数Array ( [0] => test.php ) php test.php a b c d 接收到5个参数Array ( [0]
阅读全文
摘要:fifo的文件需要提前建立好,或者用程序处理 php <?php $fifoName = "my_fifo"; // 打开命名管道进行读取 $fifo = fopen($fifoName, "r+"); if ($fifo false) { die("Unable to open FIFO: $fi
阅读全文
摘要:que.php <?php class MsgQueue { public $queue; public function __construct($queue) { $this->queue = $queue; } public function push($data, $type = 1) {
阅读全文
摘要:padding的填充方式可以根据自己需要修改 php $key = 'a7gE3fH9jKmN1pQ2rS4tU6vY8zW9xL0'; $iv = '7hJ3kQxZW45mNpR'; $data = '123456'; $encrypted = openssl_encrypt($data, 'A
阅读全文
摘要:这种是市面上比较常用的,但是需要数据库存储。或者自己写一套加解密的方法,根据code进行解密,效率更高 直接上代码 <?php function shortUrl($url) { $charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkl
阅读全文
摘要:先看一个代码 $num = 0; try { echo 1 / $num; } catch (Exception $e) { echo $e->getMessage(); } 这时候得catch是无法捕获除数为0得错误 修复 <?php function errorHandler($errno, $
阅读全文
摘要:只是为了测试,具体可以参考其他开源软件的写法 原理都是动态创建数据库,导入基础sql,包含管理员信息。然后生成一个install.lock的文件,下次进来判断有这个文件,证明是安装过了 html <!DOCTYPE html> <html lang="en"> <head> <meta charse
阅读全文
摘要:public static function lotto($weight = array()) { $roll = sprintf("%.2f", mt_rand() / mt_getrandmax() * (array_sum($weight))); $_tmpW = 0; $rollnum =
阅读全文
摘要:<?php function array_remove_by_key($data, $key){ if(!array_key_exists($key, $data)){ return $data; } $keys = array_keys($data); $index = array_search(
阅读全文
摘要:test.php <?php if (isset($_POST['upload'])) { var_dump($_FILES); move_uploaded_file($_FILES['upfile']['tmp_name'], 'up_tmp/'.time().'.dat'); exit; } ?
阅读全文
摘要:<?PHP //图像处理类 class Image { private $file; //图片地址 private $width; //图片长度 private $height; //图片长度 private $type; //图片类型 private $img; //原图的资源句柄 private
阅读全文
摘要:工作原理就是把你写好的 php 代码编译成 c,然后你可以将其以扩展.so的形式添加到 'php.ini' 文件中。功能稍微少一点,适合简单场景 安装解释器 https://github.com/zephir-lang/php-zephir-parser git clone https://gith
阅读全文

浙公网安备 33010602011771号