php
hello php
这个作者很懒,什么都没留下…
展开
-
PHP中的new self() VS new static()区别
PHP中的new self() 和 new static()原创 2022-09-28 14:20:17 · 138 阅读 · 0 评论 -
php保存session数据到mysql数据库
session_set_save_handler()方法的使用案例sql语句如下 :CREATE TABLE `session` ( `id` int(11) unsigned zerofill NOT NULL AUTO_INCREMENT, `data` varchar(255) DEFAULT NULL, `lapse_time` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_I..原创 2022-02-11 17:42:17 · 478 阅读 · 0 评论 -
apache配置和.htaccess文件相关
apache的配置文件 httpd.conf<Directory "D:/xampp/htdocs"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # N原创 2022-01-28 16:10:23 · 224 阅读 · 0 评论 -
phpstrom配置XDebug调试
(1)下载XAMPP(2) 下载phpstrom2020 (低版本很有可能不成功)(3) 配置php.ini配置文件xampp本身已经自带了xdebug扩展, 查看phpinfo配置:配置php.ini[XDebug]zend_extension="D:/xampp/php/ext/php_xdebug.dll"xdebug.remote_enable=1xdebug.remote_host=127.0.0.1xdebug.remote_port=9000xde.原创 2022-01-24 13:35:34 · 247 阅读 · 0 评论 -
nginx+php-fpm工作模式
参考:https://blog.csdn.net/u013474436/article/details/52972699第一步: 安装php安装PHP7.2(1)yum install epel-release(2)rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm安装php对应的模块(分2种方式):(3->1)第一种: yum install php72w(3->2)第二种: yum list.原创 2021-09-01 10:47:39 · 151 阅读 · 0 评论 -
PHP的fsockopen()函数的使用(一)
(1)服务端代码如下(用swoole写的tcp服务端)://测试fsockopen函数的使用**********服务端(swoole搭建服务端)$server = new Swoole\Server('0.0.0.0', 9501);$server->on('connect', function ($serv) { echo 'Starting...';});$server->on('receive', function ($serv, $fd) { echo原创 2020-12-03 09:36:04 · 539 阅读 · 0 评论 -
php数组函数: array_multisort的使用示例
$time = ['2020-09-04','2020-01-18','2020-12-12','2020-05-05','2020-02-16','2020-12-04','2020-08-08','2020-07-05'];$file = ['x.txt','a.txt','y.txt','ab.txt','b.txt','m.txt','n.txt','z.txt'];print_r(array_multisort($time,SORT_ASC,SORT_STRING,$file));.原创 2020-09-04 15:43:30 · 116 阅读 · 0 评论 -
fsockopen函数
执行以下代码, 可以帮助理解fsockopen() 函数作用class test{ public function tempTest() { // Open a socket if (!($fp = fsockopen('localhost', 80, $errno, $errstr, 15))) { die("无法连接到主机"); } // Set timout to 1 second.原创 2020-08-06 09:52:01 · 968 阅读 · 0 评论 -
php 的 fsockopen()函数相关
第一步:首先准备两个文件a.php和b.php,两个文件都放到一台服务器上,同时创建a.txt, 1.txt, 2.txt, 3.txt文件,这几个txt文件都设置777权限目录机构如下:其中a.php文件的代码如下:<?phpclass test{ /** * php异步请求 * @param $host string 主机地址 * @param $path string 路径 * @param $param arr原创 2020-08-05 16:38:19 · 393 阅读 · 0 评论 -
PHP函数之---spl_autoload_register()
spl_autoload_register 函数的功能就是把传入的函数(参数可以为回调函数或函数名称形式)注册到 SPL __autoload 函数队列中,并移除系统默认的 __autoload() 函数。一旦调用 spl_autoload_register() 函数,当调用未定义类时,系统就会按顺序调用注册到 spl_autoload_register() 函数的所有函数,而不是自动调用 _...原创 2020-01-17 11:00:20 · 759 阅读 · 0 评论 -
PHP的system函数
PHP代码如下:<?php$v = system('netstat -tnlp',$shell_return);var_dump($shell_return);var_dump($v);执行结果:Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address ...原创 2019-12-20 16:30:43 · 9887 阅读 · 0 评论 -
fsockopen函数的应用
demo如下://fsockopen()用于打开一个socket网络连接,类似与python中以下代码:"""# 初始化socketclient = socket.socket()# 链接服务端client.connect(('127.0.0.1', 8000))# 向服务端发送信息client.send(b'this is client')# 接受服务端消息,一次最多...原创 2019-12-19 16:07:28 · 323 阅读 · 0 评论 -
centos7 安装php7.2
安装PHP7.2如果报错请按照报错提示: --skip-broken进行重新安装一遍yum -y install php72* (--skip-broken)原创 2019-12-18 15:14:48 · 120 阅读 · 0 评论 -
phpstorm 连接远程服务器 自动上传和拉取代码
一、SFTP远程连接服务器1.菜单栏找到【工具/Tools】->【Deployment/部署】->【Confinguration…/配置…】2.点加号(+),添加一台服务器,填写名称,选择类型为SFTP,点击确定。3.按下图提示,填写服务器信息。填写完服务器链接信息,点击【Test SFTP Connec...原创 2019-12-10 13:15:00 · 1523 阅读 · 0 评论 -
apache不解析PHP文件,直接显示源码
最主要原因是缺少了一个php扩展:mod_phpyum install mod_php1.找到:AddType application/x-gzip .gz .tgz在其下面添加:AddType application/x-httpd-php .php //添加支持对php脚本解析2. 找到:<IfModule dir_module>Directo...原创 2019-11-25 16:32:56 · 3351 阅读 · 1 评论 -
正则表达式(?:pattern)
//(?:pattern):取消当前的这个小括号的后向引用功能,//即:后面的"\1"后向引用时候,引用的是"PHP"这个字符串,//而不是"Chapter|Section"这个字符串(这个正则表达式中虽然有两个括号,但却引用的是"PHP")$pattern = "/^(?:Chapter|Section) (PHP) \1 [1-9][0-9]{0,1}$/";$str = "Chap...原创 2019-07-31 17:41:53 · 557 阅读 · 0 评论 -
ubuntu上安装php7.0的pcntl(多进程模块)扩展
ubuntu16,php7.0:安装多进程模块pcntl1、首先检查php版本号php -v//输出版本号:我的是php7.0.332、下载对应版本的php包//我的是进入到/home下,创建php目录,把包下载到php目录中去cd /home/php///然后下载对应的php包wget http://cn2.php.net/distributions/php-7.0...原创 2019-04-10 19:11:51 · 2359 阅读 · 1 评论 -
fsockopen函数使用说明
转载:https://blog.csdn.net/fdipzone/article/details/11712607#php 利用 fsockopen GET/POST 提交表单及上传文件1.GETget.php<?php$host = 'demo.fdipzone.com';$port = 80;$errno = '';$errstr = '';$timeout =...转载 2019-06-18 17:18:35 · 1197 阅读 · 0 评论 -
phpstrom 开启debug调试模式
首先安装xdebug扩展:https://xdebug.org/download.php如下:下载后,将扩展放到php扩展文件里面:如:D:\phpStudy\PHPTutorial\php\php-7.1.13-nts\ext然后在php.ini配置文件中添加如下:[xdebug]zend_extension="D:\phpStudy\PHPTutorial\php...原创 2019-05-08 19:06:05 · 995 阅读 · 0 评论 -
php线程
<?phpclass test extends \Thread{ public $url; public $result; public function __construct($url) { $this->url = $url; } //实现Thread父类的run()方法 public func...原创 2019-04-15 12:15:06 · 276 阅读 · 0 评论 -
php对前台提交的表单数据做安全处理(防SQL注入和XSS攻击等)
/** * 防sql注入字符串转义 * @param $content 要转义内容 * @return array|string */ public static function escapeString($content) { $pattern = "/(select[\s])|(insert[\s])|(update[\s])...转载 2018-09-18 09:52:56 · 1681 阅读 · 0 评论 -
php常用函数
PHP常用函数总结数学函数1.abs(): 求绝对值$abs = abs(-4.2); //4.2 数字绝对值数字2.ceil(): 进一法取整echo ceil(9.999); // 10 浮点数进一取整3.floor(): 舍去法取整 echo floor(9.999); // 9 浮点数直接舍去小数部分4.fmod(): 浮点数取余? 1...转载 2018-07-20 11:44:22 · 263 阅读 · 0 评论 -
Windows下启动redis服务
windows下启动redis服务原创 2018-01-26 18:15:36 · 893 阅读 · 0 评论 -
phpstrom编辑远程服务器上的项目
或者做如下选择:然后弹出如下画面:原创 2018-03-29 16:27:33 · 175 阅读 · 0 评论 -
php的ffmpeg
ffmpeg-php扩展php视频缩略图,较常用的是ffmpeg-php1: 安装 ffmpegffmpeg的下载链接 http://ffmpeg.org/download.html解压安装包tar -jxvf ffmpeg-x.x.tar.bz2进入目录cd ffmpeg-x.x编译安装./configure --enable-shared && make &&...转载 2018-03-30 17:18:23 · 890 阅读 · 0 评论 -
linux安装FFmpeg
CentOS中yum安装ffmpeg1.升级系统sudo yum install epel-release -ysudo yum update -ysudo shutdown -r now2.安装Nux Dextop Yum 源由于CentOS没有官方FFmpeg rpm软件包。但是,我们可以使用第三方YUM源(Nux Dextop)完成此工作。1) CentOS 7sudo rpm --im...转载 2018-03-30 16:15:39 · 1093 阅读 · 0 评论 -
nginx、thinkphp3.2、linux配置文件配置
nginx.conf配置文件: server { listen 9001; server_name 127.0.0.1; index index.php; root /data/mobissp/mobissp_ad/; # Load configuration files for the default s...原创 2018-09-28 23:22:46 · 3483 阅读 · 0 评论 -
nginx+php测试时显示 502 bad gateway的解决方法
http://www.apelearn.com/study_v2/chapter18.html由于阿铭老师的PHP版本是 5.3的 我装了 5.5 测试出现了 502 错误 查看日志 借助nginx的错误日志来进行排查vim /usr/local/nginx/logs/nginx_error.log 显示 : connect() to unix:/tmp/php-fc...转载 2018-10-30 18:41:20 · 5277 阅读 · 0 评论 -
php的可变变量
//php可变变量$arr = ['first'=>'value1','second'=>'value2','third'=>'value3'];foreach ($arr as $key=>$value){ $$key = $value;}print_r($arr);//打印结果:['first'=>'value1','second'=>...原创 2018-11-06 18:55:43 · 253 阅读 · 0 评论 -
php生成器2
如下代码:function gen(){ $ret = (yield 'yield1'); print_r('@@@@@' . $ret); echo '<br/>'; $ret = (yield 'yield2'); print_r('######' . $ret); echo '<br/>';}$gen =...原创 2019-04-09 18:23:55 · 100 阅读 · 0 评论 -
php生成器
Iterator为php提供的生成器接口,实现该接口的下面几个方法后,就可以进行循环遍历。以下是生成器走的流程:class Number implements Iterator{ protected $i = 1; protected $key; protected $val; protected $count; public function ...转载 2019-04-09 15:47:13 · 129 阅读 · 0 评论 -
pcntl_alarm()的示例
pcntl_alarm—为进程设置一个alarm闹钟信号创建一个计时器,在指定的秒数后向进程发送一个SIGALRM信号。每次对pcntl_alarm()的调用都会取消之前设置的alarm信号。<?phppcntl_signal(SIGALRM, function () { pcntl_alarm(2); echo 'Received an alarm s...原创 2019-04-12 16:28:06 · 2233 阅读 · 0 评论 -
PHP的pcntl_signal_dispatch和posix_kill、pcntl_signal配合发送信号
先看下以下代码://注册SIGINT和SIGUSR2信号的响应pcntl_signal(SIGINT, 'signalHandler', false); //SIGINT : 2pcntl_signal(SIGUSR2, 'signalHandler', false); //SIGINT : 12function signalHandler($signal){ echo ...原创 2019-04-11 14:57:37 · 2394 阅读 · 0 评论 -
linux+php进程先关
首先参考两篇博文:https://www.cnblogs.com/dongguolei/p/8086346.htmlhttps://www.cnblogs.com/php-linux/p/7070865.html我觉其中最重要的一句话就是:在fork函数执(对应php来讲,就是pcntl_fork()函数)行完毕后,如果创建新进程成功,则出现两个进程,一个是子进程,一个是父进程。在子进...转载 2019-04-11 10:49:03 · 145 阅读 · 0 评论 -
php生成器
https://www.cnblogs.com/johnson108178/p/8007585.html转载 2019-03-11 18:42:46 · 96 阅读 · 0 评论 -
记住密码操作
//获取用户登陆信息function getParams(){ $username = trim($_POST['username']); $password = md5(trim($_POST['password'])); $ref_url = $_GET['req_url']; $remember = $_POST['remember'];//是否自动登录...原创 2018-11-05 12:09:39 · 810 阅读 · 0 评论 -
加密、解密函数
//加密函数function lockUrl($txt, $key = 'demo_string'){ $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+"; $nh = rand(0, 64); $ch = $chars[$nh]; $mdKey = md5(...转载 2018-11-02 15:55:49 · 1805 阅读 · 0 评论