随笔分类 - PHP
摘要:public bool Memcached::add ( string $key , mixed $value [, int $expiration ] ) 向key中添加值,如果key存在,返回false,$expiration 以秒为单位的整数,过期时间,例如120【2分钟后过期】 public
阅读全文
摘要:引用 pecl.php.net有两个memcache扩展: memcache memcached extension memcached PHP extension for interfacing with memcached via libmemcached library memcached 的
阅读全文
摘要:今天在Mac上安装memcached服务的时候 由于安装memcached之前需要安装libevent依赖包 所以使用brew install libevent 安装过程中报错 Warning: You are using OS X 10.11. We do not provide support
阅读全文
摘要:错误原因 没有mbstring扩展 本文只介绍Linux解决办法 方法一 编译PHP的时候 带上--enable-mbstring参数 方法二 进入PHP源码/ext/mbstring目录 ./configure --with-php-config=/php安装目录/bin/php-config m
阅读全文
摘要:解决办法 brew link openssl --force 然后 ./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config make sudo make install 如果还是不行,就去openssl官网
阅读全文
摘要:这个属于路径问题 我直接修改mysqli_api.h文件 # vim mysqli_api.h把第36行的#include "ext/mysqlnd/mysql_float_to_double.h"修改为#include "绝对路径/ext/mysqlnd/mysql_float_to_double
阅读全文
摘要:大概意思就是说找不到 opt/php7/etc/php-fpm.d/目录下的配置文件。 进入里面的目录,会有一个www.conf.default文件。执行下面命名复制一份 复制好之后,编辑该文件 定位到里面文件的 user = nobody 和 group = nobody ,调整为 www-dat
阅读全文
摘要:修改app/config/app.php文件 将key设置成长度为16,24,32的字符串
阅读全文
摘要:今天第一次配Nginx负载均衡,发现PHP无法获取HTTP_HOST 贴上的Nginx配置 echo $_SERVER['HTTP_HOST']; 输出abc.com 仔细查看Nginx配置,很容易发现PHP获取到的HTTP_HOST是Nginx代理过来的。 解决的办法有两种 方法一,将abc.co
阅读全文
摘要:function GetIP(){ if(!empty($_SERVER["HTTP_CLIENT_IP"])){ $cip = $_SERVER["HTTP_CLIENT_IP"]; }elseif(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){ $cip = $_SERVER["HTTP_X_FOR...
阅读全文
摘要:/** * 容量转换 * @param string $value 字节数值 * @return string */function GBKB($value) { $size = ($value >= 1000) ? ceil($value / 1000) . "KB" : $value . "B"
阅读全文
摘要:系统Ubuntu 安装Apache,php后发现laravel报 解决办法: apt-get install php5-mcrypt cp /etc/php5/mods-available/mcrypt.ini mcrypt.ini
阅读全文
摘要:解决方法一 @ob_end_clean(); 解决方法二 if(ob_get_contents()) ob_end_clean();
阅读全文
摘要:今天做微信支付开发,微信服务器回调的时候,会发送XML数据到我的服务器,用以往的POST,GET是获取不到的 百度了一下,应该是 $file_in = file_get_contents("php://input"); //接收post数据$xml = simplexml_load_string($
阅读全文
摘要:$string = "67. No one knows . 没有人知道。"; $s = str_replace("。", ".", $string); $s = str_replace(".", ".", $s); $s = str_replace("’", "'", $s); $s = str_r
阅读全文
摘要:server { listen 192.168.66.131:8001; server_name 192.168.66.131:8001; root E:/www/wvtuan/;index index.php index.html; log_not_found off; ...
阅读全文
摘要:今天用PHP执行一个非常耗时的文件【ps:自己有用,大概3分钟】 但是执行到一分钟后显示 nginx 504 Gateway Time-out 于是修改php-ini.php中的max_execution_time =1200;重启php,还是没用 突然明白,如果超时是php设置的问题,会报以下错误
阅读全文
摘要:今天通过curl获取百度地图接口数据,获取到居然是乱码,于是我查看是不是编码问题,发现返回的编码和自己的编码都是utf-8, 继续找原因,发现header报文中 Content-encoding 为 gzip 在网上找了一下,然后在curl参数中添加下面代码就可以了 curl_setopt($ch,
阅读全文
摘要:1.preg_match_all中的字符串的编码必须和文本编码一致,常见于网页抓取中出现; 2.GB2312是中国规定的汉字编码,也可以说是简体中文的字符集编码;GBK 是 GB2312的扩展 ,除了兼容GB2312外,它还能显示繁体中文,还有日文的假名 3,if(codition) continu
阅读全文
摘要:今天来学习简单类扩展开发实现目标为如下php的类username; } public function setName($name){ $this->username=$name; } public function __destruct(){}}?>1.先使...
阅读全文