# \#PHP

**URL:** https://www.shiqidu.com/tag/81-tag/81.md

[最新](https://www.shiqidu.com/latest.md) · [类别](https://www.shiqidu.com/categories.md) · [标签](https://www.shiqidu.com/tags.md)

---

## [PHP基于Redis简单的分布式锁实现](https://www.shiqidu.com/t/topic/1757)

<div class="topic-metadata">

**Author:** [@yeqiu](https://www.shiqidu.com/u/yeqiu)\
**回复:** 0\
**最近更新：:** [2026 年8 月 11 日 12:51 UTC](https://www.shiqidu.com/t/topic/1757 "2026-08-11T12:51:01Z")

</div>

不考虑锁自动续期情况下的最小实现 /\*\* \* 加锁 \* \* @param string $lockKey \* @param int $ex \* @return string|false \*/ private function …

---

## [CodeIgniter 查询总是失败？把最后一条 SQL 打出来](https://www.shiqidu.com/t/topic/1750)

<div class="topic-metadata">

**Author:** [@caijizhushou](https://www.shiqidu.com/u/caijizhushou)\
**回复:** 0\
**最近更新：:** [2026 年8 月 7 日 09:48 UTC](https://www.shiqidu.com/t/topic/1750 "2026-08-07T09:48:52Z")

</div>

在 CodeIgniter 老项目里排查数据库问题，经常会碰到这种情况：SQL 和绑定参数一起传给 query()，最后只拿到一个 false。继续盯着 $sql 变量看，未必能看出框架刚刚记录了哪条查询。 $query = $this-\>…

---

## [Guzzle 8.0.0 正式发布：PHP主流HTTP客户端重大破坏性版本升级](https://www.shiqidu.com/t/topic/1740)

<div class="topic-metadata">

**Author:** [@liswhe](https://www.shiqidu.com/u/liswhe)\
**回复:** 0\
**最近更新：:** [2026 年7 月 22 日 07:13 UTC](https://www.shiqidu.com/t/topic/1740 "2026-07-22T07:13:51Z")

</div>

\# Guzzle 8.0.0 正式发布：PHP主流HTTP客户端重大破坏性版本升级 Guzzle 8.0.0 重磅破坏性版本正式发布，本次更新以\*\*类型安全、安全加固、协议升级\*\*为核心，底层依赖同步升级：\`guzzlehttp/prom…

---

## [分享一些PHP面试题](https://www.shiqidu.com/t/topic/857)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2025 年8 月 26 日 09:01 UTC](https://www.shiqidu.com/t/topic/857 "2025-08-26T09:01:20Z")

</div>

1 $array = \[ 1 =\> "a", "1" =\> "b", 1.5 =\> "c", true =\> "d", \]; var\_dump($array); 2 $itemArr = \[1, 2, …

---

## [PHP Xdebug配置导致代码异常无法被捕获从而导致500错误](https://www.shiqidu.com/t/topic/854)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2025 年8 月 15 日 08:15 UTC](https://www.shiqidu.com/t/topic/854 "2025-08-15T08:15:41Z")

</div>

项目环境：laravel6 有一个自定义异常MyException继承自Exception class MyException extends Exception { public function \_\_construct(s…

---

## [一个小题目考验你的PHP基础是否牢固](https://www.shiqidu.com/t/topic/845)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2025 年5 月 23 日 06:51 UTC](https://www.shiqidu.com/t/topic/845 "2025-05-23T06:51:22Z")

</div>

下面的代码输出什么？ class TEST { public static function a() { $self = new static(); $self-\>b(); } private functio…

---

## [\[转载\] PHP8.1 新特性fiber及原理浅析](https://www.shiqidu.com/t/topic/820)

<div class="topic-metadata">

**Author:** [@caojie](https://www.shiqidu.com/u/caojie)\
**回复:** 0\
**最近更新：:** [2024 年8 月 1 日 09:09 UTC](https://www.shiqidu.com/t/topic/820 "2024-08-01T09:09:11Z")

</div>

前言 很早就听说PHP8.1出了Fiber（又称纤程），但一直也没时间捣鼓它, 正好前段时间在整理PHP的新特性/功能，想看看有没有什么可以给日常开发带来便利、安全、性能提升的，再看到它感觉跟性能有点关系， 于是就决定捣鼓一下，整理记录…

---

## [Hyperf框架Failed to open stream: DNS Lookup resolve timeout\[35\]](https://www.shiqidu.com/t/topic/819)

<div class="topic-metadata">

**Author:** [@danton](https://www.shiqidu.com/u/danton)\
**回复:** 0\
**最近更新：:** [2024 年7 月 19 日 06:48 UTC](https://www.shiqidu.com/t/topic/819 "2024-07-19T06:48:00Z")

</div>

解决办法 // server.php的settings指定dns server 'settings' =\> \[ Constant::OPTION\_ENABLE\_COROUTINE =\> true, Constant::OPT…

---

## [订单按sku和数量拆分逻辑](https://www.shiqidu.com/t/topic/816)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2024 年6 月 26 日 03:51 UTC](https://www.shiqidu.com/t/topic/816 "2024-06-26T03:51:34Z")

</div>

废了一番功夫，所以记录一下 $orderItemListByStockId = \[ "1231298956" =\> \[ \[ "id" =\> 683457815, "o…

---

## [PHP trigger\_error 函数触发的错误无法使用 ~E\_NOTICE 屏蔽](https://www.shiqidu.com/t/topic/813)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2024 年4 月 11 日 09:05 UTC](https://www.shiqidu.com/t/topic/813 "2024-04-11T09:05:54Z")

</div>

error\_reporting 配置如下 error\_reporting(E\_ALL & ~E\_NOTICE) ; 代码里使用trigger\_error出发错误。 trigger\_error("test user notice err…

---

## [有时候觉得百度的文心一言还挺聪明](https://www.shiqidu.com/t/topic/810)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2024 年3 月 21 日 06:52 UTC](https://www.shiqidu.com/t/topic/810 "2024-03-21T06:52:22Z")

</div>

问题 if ($\_POST\['activityType'\] == 1 && (empty($\_POST\['buyCount'\]\[$i\]) || empty($\_POST\['giftCount'\]\[$i\]) || $\_POST\['buyCou…

---

## [记一次homebrew安装的php5.6 执行openssl\_decrypt函数502的异常](https://www.shiqidu.com/t/topic/805)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2023 年10 月 26 日 08:04 UTC](https://www.shiqidu.com/t/topic/805 "2023-10-26T08:04:27Z")

</div>

php5.6是用homebrew安装的，用的包用的是 shivammathur/php/php@5.6 执行下面的代码 openssl\_decrypt($encrypted, $this-\>method, $this-\>key, $th…

---

## [PHP处理csv文件时，正确处理单元格内多余的逗号。](https://www.shiqidu.com/t/topic/803)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2023 年9 月 7 日 04:00 UTC](https://www.shiqidu.com/t/topic/803 "2023-09-07T04:00:07Z")

</div>

一般处理csv内容时，php多用explode(“,”, $csvLine)，但是有些csv单元格内有多余的英文逗号，如下面的从腾讯云日志里导出的nginx日志。 remote\_addr,request\_body,request\_meth…

---

## [http\_build\_query之Java实现](https://www.shiqidu.com/t/topic/801)

<div class="topic-metadata">

**Author:** [@danton](https://www.shiqidu.com/u/danton)\
**回复:** 0\
**最近更新：:** [2023 年9 月 2 日 09:11 UTC](https://www.shiqidu.com/t/topic/801 "2023-09-02T09:11:44Z")

</div>

同事Javaer对接三方支付渠道，对方只有PHP demo，签名始终不过，遂帮忙排查问题，定位到http\_build\_query，这个函数容易让Javaer误解，比较像是遍历拼接然后urlencode，所以就掉坑里了。先看下函数的定义 f…

---

## [netsuite oauth 1.0 php对接踩坑记录](https://www.shiqidu.com/t/topic/800)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2023 年8 月 28 日 07:35 UTC](https://www.shiqidu.com/t/topic/800 "2023-08-28T07:35:49Z")

</div>

业务需要对接netsuite的接口，对方接口验权是oauth1.0，根据提供的consumerKey等参数，使用postman测试了一下，可以调通。 然后写代码实现如下: // 请求URL $baseUrl = "https://…

---

## [Mac M1 PHP安装MongoDB扩展报错： fatal error: ‘pcre2.h‘ file not found 解决方案](https://www.shiqidu.com/t/topic/795)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2023 年6 月 4 日 05:43 UTC](https://www.shiqidu.com/t/topic/795 "2023-06-04T05:43:30Z")

</div>

ln -s /opt/homebrew/include/pcre2.h /opt/homebrew/Cellar/php@7.4/7.4.33/include/php/ext/pcre/pcre2.h 参考

---

## [构建LaravelS运行环境的Docker镜像](https://www.shiqidu.com/t/topic/792)

<div class="topic-metadata">

**Author:** [@danton](https://www.shiqidu.com/u/danton)\
**回复:** 0\
**最近更新：:** [2023 年2 月 26 日 15:54 UTC](https://www.shiqidu.com/t/topic/792 "2023-02-26T15:54:34Z")

</div>

需求：服务器系统自带Docker，没有包管理，传统的部署方式不太合适，遂选择Docker，此项目只需单机部署 解释：LaravelS是Laravel的加速方案，属于常驻内存应用 实现： 编写Dockerfile FROM php:…

---

## [Hyperf异步队列注解AsyncQueueMessage](https://www.shiqidu.com/t/topic/791)

<div class="topic-metadata">

**Author:** [@danton](https://www.shiqidu.com/u/danton)\
**回复:** 0\
**最近更新：:** [2023 年2 月 12 日 07:43 UTC](https://www.shiqidu.com/t/topic/791 "2023-02-12T07:43:18Z")

</div>

官方文档的使用示例 \<?php declare(strict\_types=1); namespace App\\Service; use Hyperf\\AsyncQueue\\Annotation\\AsyncQueueMessage; …

---

## [Mac安装多版本PHP和扩展](https://www.shiqidu.com/t/topic/790)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2022 年12 月 21 日 14:01 UTC](https://www.shiqidu.com/t/topic/790 "2022-12-21T14:01:19Z")

</div>

Nginx 和 Mysql 安装比较简单 直接brew install 即可。 Nginx brew install nginx MySQL brew install mysql PHP 安装低版本PHP，比如5.6 需要 tap一下 …

---

## [Mac安装mcrypt扩展的惨痛踩坑经历](https://www.shiqidu.com/t/topic/789)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 1\
**最近更新：:** [2022 年12 月 19 日 10:37 UTC](https://www.shiqidu.com/t/topic/789 "2022-12-19T10:37:39Z")

</div>

因为公司老项目里使用到了mcrypt加密函数，所以需要安装PHP的mcrypt扩展，又因为PHP版本太老是5.6，所以不能直接通过pecl安装。 $ /opt/homebrew/opt/php@5.6/bin/pecl install m…

---

## [phpstorm 安装laravel-ide-helper失败的解决办法](https://www.shiqidu.com/t/topic/786)

<div class="topic-metadata">

**Author:** [@caojie](https://www.shiqidu.com/u/caojie)\
**回复:** 0\
**最近更新：:** [2022 年8 月 2 日 08:43 UTC](https://www.shiqidu.com/t/topic/786 "2022-08-02T08:43:09Z")

</div>

直接用官方的命令 composer require --dev barryvdh/laravel-ide-helper ，报错如下： Problem 1 - barryvdh/laravel-ide-helper 2.12.x-d…

---

## [Yii2 替代 fxp/composer-asset-plugin 的方案](https://www.shiqidu.com/t/topic/777)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 2\
**最近更新：:** [2022 年5 月 17 日 09:17 UTC](https://www.shiqidu.com/t/topic/777 "2022-05-17T09:17:54Z")

</div>

Yii官方使用这个composer包来管理对 Bower 和 NPM 包的依赖，但是它是全局安装的，而且composer2.x版本无法正常使用这个包。 可以使用 yidas/yii2-bower-asset 来替代 fxp/compose…

---

## [让composer走clash for windows的系统代理。](https://www.shiqidu.com/t/topic/781)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2022 年4 月 20 日 02:56 UTC](https://www.shiqidu.com/t/topic/781 "2022-04-20T02:56:25Z")

</div>

composer update 更新依赖太慢，所以得想办法让composer能走系统代理，因为我已经安装了clash for windows，代理端口是 7890。 思路是让命令行走系统代理，在cmd里执行如下命令 set http\_p…

---

## [composer install 的 404问题（Composer\\Downloader\\TransportException）](https://www.shiqidu.com/t/topic/780)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2022 年4 月 13 日 02:07 UTC](https://www.shiqidu.com/t/topic/780 "2022-04-13T02:07:11Z")

</div>

新项目执行 composer install 报错，出现了404的问题。 \[Composer\\Downloader\\TransportException\] …

---

## [Yii2 composer install 后，vendor目录下没有bower-asset或者bower的问题](https://www.shiqidu.com/t/topic/776)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2022 年3 月 8 日 03:57 UTC](https://www.shiqidu.com/t/topic/776 "2022-03-08T03:57:53Z")

</div>

执行composer install后提示安装成功了，但是打开项目后却报错说没有bower-asset目录。 Exception 'yii\\base\\InvalidArgumentException' with message 'The …

---

## [利用Swoole Coroutine测试](https://www.shiqidu.com/t/topic/771)

<div class="topic-metadata">

**Author:** [@danton](https://www.shiqidu.com/u/danton)\
**回复:** 0\
**最近更新：:** [2022 年1 月 23 日 09:35 UTC](https://www.shiqidu.com/t/topic/771 "2022-01-23T09:35:52Z")

</div>

常用的接口压测手段有ab，JMeter等工具，那么如何自己实现呢，借助Swoole Coroutine的简易脚本测试并发下是否会超卖 Swoole\\Coroutine\\run(function () { $accessTokens…

---

## [macOS 安装Redis扩展](https://www.shiqidu.com/t/topic/768)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2022 年1 月 14 日 16:42 UTC](https://www.shiqidu.com/t/topic/768 "2022-01-14T16:42:12Z")

</div>

我的PHP是brew安装的。 目录是 /usr/local/etc/php/7.4/ phpize路径:/usr/local/opt/php@7.4/bin/phpize php-config路径:/usr/local/opt/php…

---

## [发现一种 if else 嵌套 try catch 的简化写法](https://www.shiqidu.com/t/topic/765)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 4\
**最近更新：:** [2022 年1 月 7 日 06:08 UTC](https://www.shiqidu.com/t/topic/765 "2022-01-07T06:08:19Z")

</div>

原代码 改进后的代码 看起来舒服多了。

---

## [composer install 忽略版本要求](https://www.shiqidu.com/t/topic/761)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 1\
**最近更新：:** [2022 年1 月 7 日 04:19 UTC](https://www.shiqidu.com/t/topic/761 "2022-01-07T04:19:27Z")

</div>

安装一个包，但是我的PHP8版本太高了，但是应该是可以向下兼容的，可以使用下面的命令强制安装。 composer install --ignore-platform-reqs update 同理。

---

## [解决PHP ftp\_put(): php\_connect\_nonb() failed: No error (0)](https://www.shiqidu.com/t/topic/763)

<div class="topic-metadata">

**Author:** [@Eureka](https://www.shiqidu.com/u/Eureka)\
**回复:** 0\
**最近更新：:** [2021 年12 月 16 日 08:12 UTC](https://www.shiqidu.com/t/topic/763 "2021-12-16T08:12:42Z")

</div>

连接上ftp服务器后，发现 ftp\_nlist 和 ftp\_put 都会报这个No error的错，导致无法列出目录下的文件，也没办法上传文件。 解决办法是设置一个参数 FTP\_USEPASVADDRESS 注意要放到设置被动模式的代码前…

[下一页](https://www.shiqidu.com/tag/81-tag/81.md?match_all_tags=true&page=1&tags%5B%5D=PHP)
