
PHP
暮雨疏桐
爱搬砖的伪文艺女青年
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
PHP7 用 Exception catch不到error,Throwable 才可以
【代码】PHP7 用 Exception catch不到error,Throwable 才可以。原创 2024-03-18 14:41:10 · 556 阅读 · 0 评论 -
php 获取上月 月初/月末 的 日期
【代码】php 获取上月 月初/月末 的 日期。原创 2024-03-07 15:51:01 · 1165 阅读 · 0 评论 -
PHP 和 MySQL 相关的各种超时设置
php 和 mysql 各种 timeout转载 2022-10-28 13:38:42 · 1455 阅读 · 0 评论 -
查看/杀死 PHP 进程
查看/杀死 PHP 进程。原创 2022-08-11 09:33:07 · 561 阅读 · 0 评论 -
通过宿主机的web程序,调用 docker 命令
通过宿主机的web程序,调用 docker 命令; 非 root 用户执行docker命令原创 2022-06-14 15:28:18 · 469 阅读 · 0 评论 -
cakephp2.x Shell 调用Controller里的action,
环境php:7.1 cakephp:2.x CentOS Linux release 7.4.1708确认cakephp的console是否可以正常工作#cd 到项目app目录下$ cd /path/to/cakephp/app$ ./Console/cake不加参数执行完后,执行结果如下:Welcome to CakePHP v2.10.11 Console----------------------------------------------------------.原创 2022-02-25 15:47:56 · 1054 阅读 · 0 评论 -
PHP 获取前月 月初/月末 日期
$now = '2021-03-30';echo 'now: '.$now.'<br><br>';$firstDayOfThisMonth = date("Y-m-01", strtotime($now));echo 'first day of this month: '.$firstDayOfThisMonth.'<br><br>';$lastDayOfPrevMonth = date('Y-m-d', strtotime($firstDayO.原创 2021-12-23 15:23:10 · 789 阅读 · 0 评论 -
PHP时间测试
<?php$today= date('Y-m-d');echo 'today: '.$today.'<br><br>';$one_month = date('Y-m-d',strtotime('-1 month'));echo '-1 month: '.$one_month.'<br><br>';$three_month = date('Y-m-d',strtotime('-3 month'));echo '-3 month: '.$t原创 2021-12-14 10:16:51 · 174 阅读 · 0 评论 -
try catch作用域
现象描述对应投稿的上传机能的时候定义了两个方法:上传方法 public function fileUpload(){}, 有try catch上传完成后,压缩图片的方法 private function checkImgFormat($imgPath, $mediaType){} 没有 try catch两个方法的关系是 fileUpload 中 调用了 checkImgFormat 方法一开始,checkImgFormat 中没有加 try catch逻辑,我以为 checkImgFor原创 2021-09-09 14:11:16 · 436 阅读 · 0 评论 -
PHP二十一问:PHP的垃圾回收机制
本文转自:PHP二十一问:PHP的垃圾回收机制PHP 是一门托管型语言,在 PHP 编程中,程序员不需要手工处理内存资源的分配与释放(使用 C 编写 PHP 或 Zend 扩展除外),这就意味着 PHP 本身实现了垃圾回收机制(Garbage Collection)。在 PHP 官方网站可以看到对垃圾回收机制的介绍。PHP的引用计数PHP在内核中是通过zval这个结构体来存储变量的,在Zend/zend.h文件中找到了其定义:PHP5 中定义如下:struct _zval_struct {转载 2021-09-07 15:09:50 · 581 阅读 · 0 评论 -
IP地址正则表达式
IP地址分4段,每段取值范围0-255精确写法:0-99 :[1-9]?\d100-199 :1\d{2}200-249 :2[0-4]\d250-255 :25[0-5]组合起来 (([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5]).){3}([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5])原创 2021-01-28 14:57:23 · 1475 阅读 · 0 评论 -
php判断是不是url
参考链接:https://blog.youkuaiyun.com/lianbaixue/article/details/16986433https://www.php.cn/php-ask-458467.html第一种:正则表达式function or_url($url){ $preg = "/http[s]?:\/\/[\w.]+[\w\/]*[\w.]*\??[\w=&\+\%]*/is"; if(preg_match($preg,$url)){ ...转载 2020-11-11 11:01:27 · 2052 阅读 · 0 评论 -
PHP 数字加千分位
// number_format ( float $number [, int $decimals = 0 ] ) : string// number_format ( float $number , int $decimals = 0 , string $dec_point = "." , string $thousands_sep = "," ) : string// number_format 函数可以接受1个、2个或者4个参数(注意:不能是3个):$number = 1234.5678;.原创 2020-09-30 16:11:50 · 635 阅读 · 0 评论 -
微博 PHP SDK安装教程
step 1: 从https://github.com/xiaosier/libweibo下载zip资源,解压step 2:在你本地创建一个PHP_SDK测试文件夹,将上一步获取的资源放到该路径下,我的路径是D:\www\testWbPhpApIstep 3:安装composer,安装教程请参考:https://docs.phpcomposer.com/00-intro.html 如果已安装composer,请忽略此步骤step 4:打开命令行,cd到step 2创建的路径下,执行 comp...原创 2020-07-13 10:31:04 · 288 阅读 · 0 评论 -
php格式化时间
以防忘记,做个笔记echodate("Y-m-dH:i:s",strtotime($time));原创 2020-06-17 16:54:34 · 192 阅读 · 0 评论 -
php 使用filesize函数注意事项
项目有一个视频上传的队列文件,这个文件是,有视频上传的时候,就会写入到队列文件去因为后来读写文件的时候,加了文件锁,所以,file_get_contents()就得不到文件内容了,曲线救国,就改用下前面的方法:$fileSize = filesize($filePath);$fileCont = fread($fo, $fileSize);然而,把read出来的内容再往文件里写的时...原创 2019-10-21 13:32:35 · 472 阅读 · 0 评论 -
高效 php获取文件行数
<?php$file = './test.txt';$fileCont = file_get_contents($file);echo substr_count($fileCont, "\n")."行";原创 2019-10-15 11:23:11 · 265 阅读 · 0 评论 -
计算字符串文本字数
做项目的时候,要调用Twitter的API来投稿但是有个测试投稿无论如何也发不出去,查了半天,是文本字数超了所以前后台都要进行输入字数检查查了半天,总结一下首先,前台使用js /** * 计算文本字数 * twitter 中日韩140字其他语言280字,一个表情算一个长度 * Instagram 不管什么语言 2200字 * @param String med...原创 2019-03-08 14:20:19 · 726 阅读 · 0 评论 -
PHP facebook Graph API以及Twitter twitteroauth 发投稿换行问题解决办法
做php项目要用facebook的Graph API以及Twitter twitteroauth API发投稿投稿换行一直搞不定然后就各种查,终于解决了,着这里记录总结一下参考链接:https://stackoverflow.com/questions/5583507/line-break-in-facebook-status-update-via-graph-api$bre...原创 2019-04-23 15:27:57 · 329 阅读 · 0 评论 -
PhpSpreadsheet 读取时间变数字解决方法
$cellVal= $workSheet->getCell('A1')->getValue();$toTimestamp = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($cellVal);$date = date("Y-m-d", $toTimestamp );参考:https://stackoverflo...原创 2019-05-16 14:57:53 · 6735 阅读 · 2 评论 -
PHP 大文件上传应注意的几个size配置
在用dropzone上传大文件的时候,返回的值是以下错误:<b>Warning</b>: POST Content-Length of 9522601 bytes exceeds the limit of 8388608 bytes in <b>Unknown</b> on line <b>0</b><br /&g...原创 2019-07-08 15:55:09 · 261 阅读 · 0 评论 -
Dropzonejs + php 实现大文件分段上传
关于Dropzone的安装 以及 初始化,大家可参考:https://segmentfault.com/a/1190000004045240首先,js的代码:function initDropzone(dropzone_id){ Dropzone.autoDiscover = false;// 抑制Uncaught Error: Dropzone already attache...原创 2019-07-19 17:10:03 · 1362 阅读 · 0 评论 -
LInux 安装 ImageMagick扩展
安装命令如下 :wget https://imagemagick.org/download/ImageMagick.tar.gztar -xzf ImageMagick.tar.gzcd ImageMagick-7.0.8-60./configuremakemake installldconfig /usr/local/lib/usr/local/bin/convert log...原创 2019-08-26 15:19:20 · 425 阅读 · 0 评论 -
Fatal Error (4): syntax error, unexpected '?', expecting variable (T_VARIABLE) in ...
这两天用Instagram API 发视频投稿的时候遇到了标题上的错误原因是 ? 是php7.1的新特性以防忘记,记录一下,希望能帮到同行们参考:https://www.php.net/manual/zh/migration71.new-features.php...原创 2019-09-11 10:22:04 · 3706 阅读 · 0 评论 -
Linux上确认php.ini里memory_limit,post_max_size,upload_max_filesize配置确认
[test@ip-125-125-125-125 ~]$ echo '<?php phpinfo(); ?>' | php 2>&1 |grep -i memory_limitmemory_limit => 128M => 128M[test@ip-125-125-125-125 ~]$ echo '<?php phpinfo(); ?>...原创 2019-09-12 09:49:22 · 862 阅读 · 0 评论 -
php 当前日期加一天和指定日期加一天
本文转载于https://blog.youkuaiyun.com/qq_37506868/article/details/777226271.给当前时间加一天?一小时?<?phpecho "今天:",date('Y-m-d H:i:s'),"<br>";echo "明天:",date('Y-m-d H:i:s',strtotime('+1 day'));?>上一行输出...转载 2019-09-25 10:59:50 · 1316 阅读 · 0 评论 -
PHP 跨月数据处理
// 计算开始日可结束日之间相差多少天$datetime1 = new DateTime($fromDay);$datetime2 = new DateTime($toDay);$intDate = intval( $datetime1->diff($datetime2)->format('%a') );for ($d=0; $d<=$intDate; $d++){...原创 2019-09-25 11:12:38 · 384 阅读 · 0 评论 -
多用户同时操作一条数据问题解决,A用户先保存了,B用户后保存将A的修改改覆盖掉了
现象描述如下1,担当和管理员同时打开同一个投稿做进行编辑。2,担当点击删除,更新delete_flg字段为删除状态,然后投稿就不在画面上显示了。3,管理员的编辑还在,然后点击保存之后,正常保存了。4,担当来再更新页面,那个投稿又回来了。管理员的操作将担当的操作覆盖掉了网上查了一同,发现一种解决觉办法,现记录一下:◎乐观锁1、表中增加:最后修改时间、最后修改人;2、打开时就读...原创 2019-09-25 15:35:02 · 2348 阅读 · 0 评论 -
Linux 查看php进程命令
ps -ef |grep php原创 2019-10-09 09:52:43 · 5555 阅读 · 0 评论 -
PHP文件操作之,插入某行,删除某行,获取行号
本文转载自:https://blog.youkuaiyun.com/u011650048/article/details/17163255#在需要查找的内容后一行新起一行插入内容 function insertAfterTarget($filePath, $insertCont, $target) { $result = null; $fileC...转载 2019-10-10 15:17:30 · 464 阅读 · 0 评论 -
MySQL中如何插入反斜杠,反斜杠被吃掉,反斜杠转义之我见
问题描述:mysql中带有反斜杠的内容入库后,发现反斜杠无故失踪了(俗话说被吃掉了)例:插入insert into tb('url') values('absc\eeee'); 结果数据库里的内容是:absceeee(反斜杠没了呢)这么详细了相信大家都搞清楚问题了吧,下面看解决方案。解决方案:用addslashes(),mysql_escape_string()等函数进行处理,也就是在...转载 2019-01-08 14:55:36 · 2565 阅读 · 0 评论