<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>运达&#039;s  blog &#187; php</title>
	<atom:link href="https://www.yunda51.com/?feed=rss2&#038;tag=php" rel="self" type="application/rss+xml" />
	<link>https://www.yunda51.com</link>
	<description>运达的博客</description>
	<lastBuildDate>Wed, 12 Nov 2025 07:58:26 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.19</generator>
	<item>
		<title>MacOs下本地docker部署Nginx+Php详细流程</title>
		<link>https://www.yunda51.com/?p=1989</link>
		<comments>https://www.yunda51.com/?p=1989#comments</comments>
		<pubDate>Wed, 17 Jan 2024 08:12:30 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[docker]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[MacOs]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1989</guid>
		<description><![CDATA[大家好，今天实操一下本地docker如何部署Nginx+Php详细步骤，随着 Docker 容器化技术的不断发<a href="https://www.yunda51.com/?p=1989" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>大家好，今天实操一下本地docker如何部署Nginx+Php详细步骤，随着 Docker 容器化技术的不断发展，它已经成为了现代软件开发和部署中不可或缺的一部分。Docker 提供了一种轻量级、可移植的方式来打包和运行应用程序，使开发人员能够在不同的环境中轻松地部署和管理应用程序，废话不多说。<br />
<strong>1、docker下载：</strong><br />
进入Docker官网（<a href="https://www.docker.com/get-started/" title="docker官网">https://www.docker.com/get-started/</a>），如图位置，点击mac版本的docker下载：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2024/01/docker.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/docker.jpg" alt="docker" width="2726" height="1270" class="alignnone size-full wp-image-1990" /></a><br />
安装后，点击图标：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2024/01/1.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/1.jpg" alt="1" width="374" height="276" class="alignnone size-full wp-image-1993" /></a><br />
<strong>1.1、配置docker下载镜像:</strong><br />
<a href="http://www.yunda51.com/wp-content/uploads/2024/01/1.2.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/1.2.jpg" alt="1.2" width="2540" height="1430" class="alignnone size-full wp-image-1996" /></a><br />
<a href="http://www.yunda51.com/wp-content/uploads/2024/01/1.3.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/1.3.jpg" alt="1.3" width="2540" height="1430" class="alignnone size-full wp-image-1997" /></a></p>
<pre class="wp-code-highlight prettyprint">
&quot;registry-mirrors&quot;: [
    &quot;https://docker.mirrors.ustc.edu.cn/&quot;,
    &quot;https://hub-mirror.c.163.com/&quot;,
    &quot;https://reg-mirror.qiniu.com&quot;
  ]
</pre>
<p><strong>1.2、在本地建好对应映射关系的文件夹</strong><br />
<a href="http://www.yunda51.com/wp-content/uploads/2024/01/1.4.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/1.4.jpg" alt="1.4" width="1526" height="862" class="alignnone size-full wp-image-1998" /></a><br />
我的本地映射文件目录~/docker-nmp/nginx<br />
<strong>1.3、打开你的终端：</strong><br />
执行：docker -v会显示你当前docker版本好，表示docker安装成功。<br />
<a href="http://www.yunda51.com/wp-content/uploads/2024/01/1.5.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/1.5.jpg" alt="1.5" width="686" height="64" class="alignnone size-full wp-image-2000" /></a><br />
<strong>2、安装Nginx：</strong><br />
使用docker pull命令，在线拉取nginx镜像，如果没有特殊版本需求，可直接输入nginx:latest</p>
<pre class="wp-code-highlight prettyprint">
执行命令：docker pull nginx:latest
</pre>
<p>执行完成之后，你可以在docker desktop上，可以点击images选项进行查看，镜像是否拉取成功。<br />
如图所示：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2024/01/2.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/2.jpg" alt="2" width="2538" height="1428" class="alignnone size-full wp-image-2001" /></a><br />
或者你可以在终端输入：docker images 查看，如图：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2024/01/2.1.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/2.1.jpg" alt="2.1" width="940" height="658" class="alignnone size-full wp-image-2002" /></a><br />
<strong>3、安装PHP：</strong><br />
我安装的是PHP7.4版本，大家可以根据自己情况去安装不同版本,如果没有版本需求，也可以输入php:latest</p>
<pre class="wp-code-highlight prettyprint">
执行命令：docker pull php:7.4-fpm
</pre>
<p><strong>4、启动PHP容器：</strong></p>
<pre class="wp-code-highlight prettyprint">
执行：docker run --name myphp-fpm -v ~/docker-nmp/nginx/www:/www -d 38f2b691dcb8
</pre>
<pre class="wp-code-highlight prettyprint">
下面我来解释一下：
--name  myphp-fpm : 将容器命名为 myphp-fpm。
-v ~/docker-nmp/nginx/www:/www：是我在本地创建的一个文件目录，用来将主机中项目的目录 www 挂载到容器的 /www
38f2b691dcb8：是php的镜像ID。
</pre>
<p><a href="http://www.yunda51.com/wp-content/uploads/2024/01/3.1.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/3.1.jpg" alt="3.1" width="1130" height="598" class="alignnone size-full wp-image-2004" /></a><br />
容器启动正常，可以使用命令行来查看：</p>
<pre class="wp-code-highlight prettyprint">
执行：docker ps
</pre>
<p><a href="http://www.yunda51.com/wp-content/uploads/2024/01/3.2.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/3.2.jpg" alt="3.2" width="1798" height="124" class="alignnone size-full wp-image-2007" /></a><br />
创建:  ~/docker-nmp/nginx/conf/conf.d 目录：</p>
<pre class="wp-code-highlight prettyprint">
mkdir ~/docker-nmp/nginx/conf/conf.d
</pre>
<p>在该目录下添加 ~/docker-nmp/nginx/conf/conf.d/coonote-test-php.conf 文件，内容如下：</p>
<pre class="wp-code-highlight prettyprint">
server {
    listen       80;
    server_name  localhost;
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm index.php;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    location ~ \.php$ {
        fastcgi_pass   php:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /www/$fastcgi_script_name;
        include        fastcgi_params;
    }
}
</pre>
<p>配置文件说明：<br />
php:9000: 表示 php-fpm 服务的 URL，下面我们会具体说明。<br />
/www/: 是 myphp-fpm 中 php 文件的存储路径，映射到本地的 ~/docker-nmp/nginx/www 目录。<br />
<strong>5、启动Nginx容器并关联PHP，这一步很重要</strong></p>
<pre class="wp-code-highlight prettyprint">
docker run --name coonote-php-nginx -p 8083:80 -d \
-v ~/docker-nmp/nginx/www:/usr/share/nginx/html:ro \
-v ~/docker-nmp/nginx/conf/conf.d:/etc/nginx/conf.d:ro \
--link myphp-fpm:php \
nginx
</pre>
<p>命令说明：<br />
-p 8083:80: 端口映射，把 nginx 中的 80 映射到本地的 8083 端口。<br />
~/docker-nmp/nginx/www: 是本地 html 文件的存储目录，/usr/share/nginx/html 是容器内 html 文件的存储目录。<br />
~/docker-nmp/nginx/conf/conf.d: 是本地 nginx 配置文件的存储目录，/etc/nginx/conf.d 是容器内 nginx 配置文件的存储目录。<br />
--link myphp-fpm:php: 把 myphp-fpm 的网络并入 nginx，并通过修改 nginx 的 /etc/hosts，把域名 php 映射成 127.0.0.1，让 nginx 通过 php:9000 访问 php-fpm。<br />
接下来我们在 ~/docker-nmp/nginx/www 目录下创建 index.php，代码如下：</p>
<pre class="wp-code-highlight prettyprint">
&lt;?php
    echo phpinfo();
?&gt;
</pre>
<p>打开浏览器输入：http://localhost:8083/index.php显示如下：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2024/01/4.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2024/01/4.jpg" alt="4" width="2320" height="1424" class="alignnone size-full wp-image-2008" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1989</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP操作redis(list)队列操作</title>
		<link>https://www.yunda51.com/?p=1976</link>
		<comments>https://www.yunda51.com/?p=1976#comments</comments>
		<pubDate>Sun, 24 Dec 2023 13:13:32 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Redis]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[redis]]></category>
		<category><![CDATA[抢购]]></category>
		<category><![CDATA[队列]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1976</guid>
		<description><![CDATA[好久没有更新文章了。 list使用场景如下： 消息队列 list类型的lpop和rpush（或者反过来，lpu<a href="https://www.yunda51.com/?p=1976" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p><strong>好久没有更新文章了。</strong><br />
list使用场景如下：<br />
<strong>消息队列</strong><br />
list类型的lpop和rpush（或者反过来，lpush和rpop）能实现队列的功能，故而可以用Redis的list类型实现简单的点对点的消息队列。<br />
<strong>最新列表</strong><br />
list类型的lpush命令和lrange命令能实现最新列表的功能，每次通过lpush命令往列表里插入新的元素，<br />
然后通过lrange命令读取最新的元素列表，比如评论列表、朋友圈的点赞列表。</p>
<p><strong>######消息队列demo,简单模拟抢购商品#####</strong></p>
<pre class="wp-code-highlight prettyprint">
$redis = new redis();
$redis-&gt;connect(&#039;127.0.0.1&#039;, 6379);
$redis-&gt;auth(&#039;123456&#039;);
$redis-&gt;flushAll(); //清空所有数据
/***入列***/
//用户点击抢购的时候，把商品信息存入消息队列
$key = &#039;product1&#039;;#商品1
for ($i = 0; $i &lt; 100; $i++) {
    $uid = rand(1000, 9999);
    $number = 10; //次数，假设这件商品只能10个人抢购
    if ($number &gt; $redis-&gt;lLen($key)) {
        $redis-&gt;rpush($key, $uid); //不够10个就入列
    } else {
        continue;
    }
}
/***出列***/
while (true){
    $flag = $redis-&gt;exists($key);
    if($flag){
        $uid = $redis-&gt;rpop($key);
        echo $uid .&quot;抢购成功！，进行订单处理操作&lt;br/&gt;&quot;;
    } else {
        echo &quot;出列完毕！&quot;;
        exit;
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1976</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何实现全国快递物流查询</title>
		<link>https://www.yunda51.com/?p=1970</link>
		<comments>https://www.yunda51.com/?p=1970#comments</comments>
		<pubDate>Sun, 26 Nov 2023 15:02:31 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[快递查询]]></category>
		<category><![CDATA[物流查询]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1970</guid>
		<description><![CDATA[PHP如何实现全国快递物流查询-快递查询 以下代码是测试好的，可以拿去直接使用。 &#60;?php error<a href="https://www.yunda51.com/?p=1970" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>PHP如何实现全国快递物流查询-快递查询<br />
以下代码是测试好的，可以拿去直接使用。</p>
<pre class="wp-code-highlight prettyprint">
&lt;?php
	error_reporting(E_ALL || ~E_NOTICE);
	$host = &quot;https://wuliu.market.alicloudapi.com&quot;;//api访问链接
	$path = &quot;/kdi&quot;;//API访问后缀
	$method = &quot;GET&quot;;
	$appcode = &quot;d923462151414d73a4a16f6a7730bb68&quot;;//开通服务后 买家中心-查看AppCode
	$headers = array();
	array_push($headers, &quot;Authorization:APPCODE &quot; . $appcode);
	// $querys = &quot;no=462319523534879&amp;type=YUNDA&quot;;  //参数写在这里
	$querys = &quot;no=JDVE09474960402&quot;;  //参数写在这里
	$bodys = &quot;&quot;;
	$url = $host . $path . &quot;?&quot; . $querys;
	// echo $url;die;
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($curl, CURLOPT_FAILONERROR, false);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($curl, CURLOPT_HEADER, true);
	if (1 == strpos(&quot;$&quot; . $host, &quot;https://&quot;)) {
	    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	}
	$out_put = curl_exec($curl);

	$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
	list($header, $body) = explode(&quot;\r\n\r\n&quot;, $out_put, 2);
	if ($httpCode == 200) {
	    print(&quot;正常请求计费(其他均不计费)&lt;br&gt;&quot;);
	    print($body);
	} else {
	    if ($httpCode == 400 &amp;&amp; strpos($header, &quot;Invalid Param Location&quot;) !== false) {
	        print(&quot;参数错误&quot;);
	    } elseif ($httpCode == 400 &amp;&amp; strpos($header, &quot;Invalid AppCode&quot;) !== false) {
	        print(&quot;AppCode错误&quot;);
	    } elseif ($httpCode == 400 &amp;&amp; strpos($header, &quot;Invalid Url&quot;) !== false) {
	        print(&quot;请求的 Method、Path 或者环境错误&quot;);
	    } elseif ($httpCode == 403 &amp;&amp; strpos($header, &quot;Unauthorized&quot;) !== false) {
	        print(&quot;服务未被授权（或URL和Path不正确）&quot;);
	    } elseif ($httpCode == 403 &amp;&amp; strpos($header, &quot;Quota Exhausted&quot;) !== false) {
	        print(&quot;套餐包次数用完&quot;);
	    } elseif ($httpCode == 403 &amp;&amp; strpos($header, &quot;Api Market Subscription quota exhausted&quot;) !== false) {
	        print(&quot;套餐包次数用完，请续购套餐&quot;);
	    } elseif ($httpCode == 500) {
	        print(&quot;API网关错误&quot;);
	    } elseif ($httpCode == 0) {
	        print(&quot;URL错误&quot;);
	    } else {
	        print(&quot;参数名错误 或 其他错误&quot;);
	        print($httpCode);
	        $headers = explode(&quot;\r\n&quot;, $header);
	        $headList = array();
	        foreach ($headers as $head) {
	            $value = explode(&#039;:&#039;, $head);
	            $headList[$value[0]] = $value[1];
	        }
	        print($headList[&#039;x-ca-error-message&#039;]);
	    }
	}
?&gt;
</pre>
<p><strong>详见：</strong><br />
阿里全国物流接口链接：https://market.aliyun.com/products/57126001/cmapi021863.html?userCode=dligum2z</p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1970</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>检测身份证号与姓名是否匹配（阿里云API接口）</title>
		<link>https://www.yunda51.com/?p=1968</link>
		<comments>https://www.yunda51.com/?p=1968#comments</comments>
		<pubDate>Sun, 26 Nov 2023 14:57:42 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[身份证号检测]]></category>
		<category><![CDATA[阿里云Api]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1968</guid>
		<description><![CDATA[直接上代码： /** * 检测身份证号与姓名是否匹配（阿里云API接口） * @return void * @<a href="https://www.yunda51.com/?p=1968" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>直接上代码：</p>
<pre class="wp-code-highlight prettyprint">
/**
 * 检测身份证号与姓名是否匹配（阿里云API接口）
 * @return void
 * @throws \think\db\exception\DataNotFoundException
 * @throws \think\db\exception\DbException
 * @throws \think\db\exception\ModelNotFoundException
 */
public function is_card(){
     $data = $this-&gt;request-&gt;post();
     $host = &quot;https://lfeid.market.alicloudapi.com&quot;;
	 $path = &quot;/idcheck/lifePost&quot;;
	 $method = &quot;POST&quot;;
	 $appcode = &quot;d923462151414d73a4a16f6a7730bb68&quot;;
	 $headers = array();
	 array_push($headers, &quot;Authorization:APPCODE &quot; . $appcode);
	 //根据API的要求，定义相对应的Content-Type
	 array_push($headers, &quot;Content-Type&quot;.&quot;:&quot;.&quot;application/x-www-form-urlencoded; charset=UTF-8&quot;);
	 $querys = &quot;&quot;;
	 $bodys = &quot;cardNo=&#039;&quot;.$data[&#039;cardNo&#039;].&quot;&#039;&amp;realName=&#039;&quot;.$data[&#039;realName&#039;].&quot;&#039;&quot;;
	 $bodys = str_replace(&quot;&#039;&quot;, &#039;&#039;, $bodys);
	// $bodys = &quot;cardNo=130432199206170113&amp;realName=刘运达&quot;;
	 $url = $host . $path;
	 $curl = curl_init();
	 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
	 curl_setopt($curl, CURLOPT_URL, $url);
	 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
	 curl_setopt($curl, CURLOPT_FAILONERROR, false);
	 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	 curl_setopt($curl, CURLOPT_HEADER, true);
	 if (1 == strpos(&quot;$&quot;.$host, &quot;https://&quot;))
	 {
	     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	 }
	 curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
	 var_dump(curl_exec($curl));
}
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1968</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>手机端的H5页面自定义分享到微信朋友、朋友圈</title>
		<link>https://www.yunda51.com/?p=1966</link>
		<comments>https://www.yunda51.com/?p=1966#comments</comments>
		<pubDate>Sun, 26 Nov 2023 14:53:17 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[H5]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[微信]]></category>
		<category><![CDATA[朋友圈]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1966</guid>
		<description><![CDATA[最近在工作中遇到了一个功能，需要将我们手机端的H5页面自定义分享到微信朋友、朋友圈、QQ和QQ空间。 下面是我<a href="https://www.yunda51.com/?p=1966" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>最近在工作中遇到了一个功能，需要将我们手机端的H5页面自定义分享到微信朋友、朋友圈、QQ和QQ空间。<br />
下面是我自己百度，然后自己亲身测试得到的一个方法；下面分享给大家，相互学习。<br />
实现原理：H5的自定义分享需要用到微信公众平台的分享接口，也就是微信网页开发中的JSSDK,【具体的说明文档：https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html】使用微信的SDK中的分享接<br />
示例：https://m.php.cn/faq/538242.html<br />
获取流程：<br />
1、获取 access_token<br />
2、通过access_token换取 jsapi_ticket<br />
3、签名算法<br />
签名生成规则如下：参与签名的字段包括noncestr（随机字符串）, 有效的jsapi_ticket, timestamp（时间戳）, url（当前网页的URL，不包含#及其后面部分） 。对所有待签名参数按照字段名的ASCII 码从小到大排序（字典序）后，使用URL键值对的格式（即key1=value1&#038;key2=value2…）拼接成字符串string1。这里需要注意的是所有参数名均为小写字符。对string1作sha1加密，字段名和字段值都采用原始值，不进行URL 转义。<br />
因为获取access_token不能请求，请求次数过多微信会把IP禁用，所以需要把access_token缓存起来，要不存到数据库里，两种方法，看自己选择。<br />
<strong>二、在数据库中添加access_token表：</strong></p>
<pre class="wp-code-highlight prettyprint">
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for access_token
-- ----------------------------
DROP TABLE IF EXISTS access_token;
CREATE TABLE access_token (
id int(11) NOT NULL AUTO_INCREMENT,
access_token char(64) NOT NULL COMMENT &#039;令牌-唯一标识&#039;,
expires_time varchar(64) DEFAULT NULL COMMENT &#039;过期时间&#039;,
ticket char(64) NOT NULL COMMENT &#039;临时票据&#039;,
ticket_expires_time varchar(64) DEFAULT NULL COMMENT &#039;过期的票据时间&#039;,
PRIMARY KEY (id)
</pre>
<p><strong>三、具体实现方式</strong><br />
1、获取access_token（access_token 的有效时间是7200s，故可以采用文件存储的方法进行保存，避免多次请求；）</p>
<pre class="wp-code-highlight prettyprint">
/**
* 添加微信分享接口
* 第一步：获取access token
*/
public function getAccessToken(){
$appid = &#039;wx207546bd5b43c838&#039;;
$secret = &#039;0ea9ee069f0dee52861aa460bed26452&#039;; //用户唯一凭证密钥
$time = time()+7000; //当前时间+2小时等于过期时间
$res = file_get_contents(&#039;https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid=&#039; .$appid.&#039;&amp;secret=&#039;. $secret);
$res = json_decode($res, true);
$token = $res[&#039;access_token&#039;];
if($token){
$insert_data[&#039;access_token&#039;] = $token;
$insert_data[&#039;expires_time&#039;] = $time;
//把获得的token存储到数据库中
$model = Db::table(&quot;access_token&quot;)-&gt;insert($insert_data);
}
return $token;
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1966</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP生成8位单个邀请码/8位卡密</title>
		<link>https://www.yunda51.com/?p=1917</link>
		<comments>https://www.yunda51.com/?p=1917#comments</comments>
		<pubDate>Tue, 13 Sep 2022 08:12:29 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php技术]]></category>
		<category><![CDATA[8位卡密]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[邀请码]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1917</guid>
		<description><![CDATA[/**PHP生成8位单个邀请码/8位卡密 * @return string **/ public functi<a href="https://www.yunda51.com/?p=1917" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<pre class="wp-code-highlight prettyprint">/**PHP生成8位单个邀请码/8位卡密
 * @return string
**/
    public function make_invite_code(){
        $code=&quot;ABCDEFGHIGKLMNOPQRSTUVWXYZ&quot;;
        $rand=$code[rand(0,25)].strtoupper(dechex(date(&#039;m&#039;))).date(&#039;d&#039;).substr(time(),-5).substr(microtime(),2,5).sprintf(&#039;%02d&#039;,rand(0,99));
        for(
                $a = md5( $rand, true ),
                $s = &#039;0123456789ABCDEFGHIJKLMNOPQRSTUV&#039;,
                $d = &#039;&#039;,
                $f = 0;
                $f &amp;lt; 8;
                $g = ord($a[$f]), // ord（）函数获取首字母的 的 ASCII值
                $d .= $s[($g ^ ord( $a[ $f + 8 ] ) ) - $g &amp;amp; 0x1F ],  //按位亦或，按位与。
                $f++
        );
        return $d;
    }
 
</pre>
<pre class="wp-code-highlight prettyprint">   
 /**
 * 生成不重复的随机数字(不能超过10位数，否则while循环陷入死循环)
 * @param  int $start 需要生成的数字开始范围
 * @param  int $end 结束范围
 * @param  int $length 需要生成的随机数个数
 * @return number      生成的随机数
 */
function getRandNumber($start = 0, $end = 9, $length = 8)
{
    //初始化变量为0
    $count = 0;
    //建一个新数组
    $temp = array();
    while ($count &amp;lt; $length) {
        //在一定范围内随机生成一个数放入数组中
        $temp[] = mt_rand($start, $end);
        //$data = array_unique($temp);
        //去除数组中的重复值用了“翻翻法”，就是用array_flip()把数组的key和value交换两次。这种做法比用 array_unique() 快得多。
        $data = array_flip(array_flip($temp));
        //将数组的数量存入变量count中
        $count = count($data);
    }
    //为数组赋予新的键名
    shuffle($data);
    //数组转字符串
    $str = implode(&quot;,&quot;, $data);
    //替换掉逗号
    $number = str_replace(&#039;,&#039;, &#039;&#039;, $str);
    return $number;
}
 
echo getRandNumber(0, 9, 8).&quot;
&quot;;

</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1917</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOs7编译安装LNMP环境(nginx+mysql+php)</title>
		<link>https://www.yunda51.com/?p=1806</link>
		<comments>https://www.yunda51.com/?p=1806#comments</comments>
		<pubDate>Tue, 12 Sep 2017 08:14:46 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1806</guid>
		<description><![CDATA[最近重新整理下LNMP环境搭建的步骤： 1.1路径说明： 1、安装包存放目录： /app/tool/ 2、软件<a href="https://www.yunda51.com/?p=1806" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>最近重新整理下LNMP环境搭建的步骤：<br />
1.1路径说明：<br />
1、安装包存放目录： /app/tool/<br />
2、软件安装目录：/app/soft/<br />
3、项目存放目录：/app/www/<br />
4、提示：管理用户是www<br />
5、启动路径：</p>
<pre class="wp-code-highlight prettyprint">1) mysql：/etc/init.d/mysqld {start|stop|restart}
2) php：/app/soft/php5.6.16/sbin/php-fpm
3) nginx：/app/soft/nginx/sbin/nginx -t &amp;amp;&amp;amp; /app/soft/nginx/sbin/nginx -s reload
</pre>
<p>设置开机自动启动：<br />
<strong>编辑：</strong></p>
<pre class="wp-code-highlight prettyprint">
vim /etc/rc.local
</pre>
<p><strong>添加：</strong></p>
<pre class="wp-code-highlight prettyprint">
#开机启动mysql服务
/etc/init.d/mysqld start
#开机启动php服务
/app/soft/php5.6.16/sbin/php-fpm
#开机启动Nginx服务
/app/soft/nginx/sbin/nginx
#关闭防火墙
systemctl stop firewalld.service
</pre>
<p><strong>mysql的安装（版本：mysql-5.5.25）：</strong><br />
1、上传cmake-2.8.8.tar.gz mysql-5.5.25.tar.gz<br />
2、安装编译MySQL过程中需要的依赖包：</p>
<pre class="wp-code-highlight prettyprint">yum install ncurses-devel libaio-devel -y
yum install gcc-c++ -y
</pre>
<p>3、安装编译安装需要的软件：</p>
<pre class="wp-code-highlight prettyprint">cd /app/tool/
tar zxvf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure 
gmake
gmake install
</pre>
<p>4、开始安装MySQL，在主服务器上搭建MySQL：</p>
<pre class="wp-code-highlight prettyprint">useradd mysql -s /sbin/nologin -M
tar zxf mysql-5.5.25.tar.gz 
cd mysql-5.5.25
cmake . -DCMAKE_INSTALL_PREFIX=/app/soft/mysql-5.5.25 \
-DMYSQL_DATADIR=/app/soft/mysql-5.5.25/data \
-DMYSQL_UNIX_ADDR=/app/soft/mysql-5.5.25/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
make   
make install
ln -s mysql-5.5.25/ /app/soft/mysql     //创建MySQL软连接
echo &#039;PATH=&quot;/app/soft/mysql/bin/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin&quot;&#039;&amp;gt;&amp;gt;/etc/profile
. /etc/profile
</pre>
<p>5、配置MySQL初始数据，并启动:</p>
<pre class="wp-code-highlight prettyprint">chmod 755 /app/soft/mysql/scripts/mysql_install_db 
/app/soft/mysql/scripts/mysql_install_db --basedir=/app/soft/mysql/ --datadir=/app/soft/mysql/data/ --user=mysql
##如果在这个环节出现了/app/soft/mysql/scripts/mysql_install_db 不存在的报错时，重新进行编译安装。
cp /app/soft/mysql/support-files/my-small.cnf /etc/my.cnf
cp /app/soft/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld   //授予执行的权限
mysql_secure_installation #设置Mysql密码
/etc/init.d/mysqld start  //重新启动
</pre>
<p>至此，MySQL编译安装完成。</p>
<p><strong>Nginx安装（版本：nginx-1.9.9）：</strong><br />
nginx使用的是一键安装脚本：安装的是nginx-1.9.9版本（你可以创建一个.sh，把下面脚本代码拷贝进去直接执行）</p>
<pre class="wp-code-highlight prettyprint">#!/bin/sh
####################################################
#This is a shell scripts to one-key install for lnmp  
#######################start########################
cd /app/tool &amp;amp;&amp;amp;\
[ -f nginx-1.9.9.tar.gz ] || wget http://nginx.org/download/nginx-1.9.9.tar.gz
[ -f pcre-8.37.tar.gz ] || wget http://sourceforge.net/projects/pcre/files/pcre/8.37/pcre-8.37.tar.gz/download
#####################install libpcre################
tar zxf pcre-8.37.tar.gz
cd ./pcre-8.37 &amp;amp;&amp;amp;\
./configure
make &amp;amp;&amp;amp; make install
cd .. &amp;amp;&amp;amp;\
rm -rf ./pcre-8.37
######################install nginx#################
cd /app/tool &amp;amp;&amp;amp; tar zxf nginx-1.9.9.tar.gz
cd ./nginx-1.9.9
mkdir /app/soft/nginx-1.9.9
useradd nginx -s /sbin/nologin -M
yum install openssl* gd-devel -y
./configure --user=nginx --group=nginx --prefix=/app/soft/nginx-1.9.9 --with-http_image_filter_module --with-http_stub_status_module --with-http_ssl_module
make &amp;amp;&amp;amp; make install
#######################test install#################
ln -s /app/soft/nginx-1.9.9/ /app/soft/nginx
cd /app/soft
if [ $? -eq 0 ];then
  echo &quot;/usr/local/lib&quot; &amp;gt;&amp;gt; /etc/ld.so.conf
  ldconfig
  /app/soft/nginx-1.9.9/sbin/nginx
  if [ $? -eq 0 ];then
     echo &quot;service nginx start&quot;
     echo  `lsof -i :80`
  fi
fi
</pre>
<p><strong>PHP安装步骤：</strong><br />
php使用的是编译安装，安装的是php-5.6.16版本<br />
###安装依赖环境包</p>
<pre class="wp-code-highlight prettyprint">yum -y install curl-devel
yum -y install libxslt-deve
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libevent libevent-devel
yum install zlib libxml libjpeg freetype libpng gd curl libiconv mysql-devel zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt* -y
yum -y install libxslt-deve
cd /app/tool/
</pre>
<p>下载libmcrypt（PHPlibmcrypt模块）<br />
安装libmcrypt</p>
<pre class="wp-code-highlight prettyprint">cd /usr/local/src
tar zxvf libmcrypt-2.5.7.tar.gz   #解压
cd libmcrypt-2.5.7      #进入目录
./configure      #配置
make    #编译
make install #安装
</pre>
<p>下载mhash并安装：</p>
<pre class="wp-code-highlight prettyprint">wget http://jaist.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make &amp;amp;&amp;amp; make install
</pre>
<p>下载mcrypt并安装：</p>
<pre class="wp-code-highlight prettyprint">wget http://jaist.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make &amp;amp;&amp;amp; make install
</pre>
<p>下载libiconv并安装：</p>
<pre class="wp-code-highlight prettyprint">wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.13.tar.gz
tar zxf libiconv-1.13.tar.gz
cd libiconv-1.13
./configure --prefix=/usr/local/libiconv
make &amp;amp;&amp;amp; make install

echo &quot;/usr/local/lib&quot; &amp;gt;&amp;gt;/etc/ld.so.conf
rm -f /usr/lib/libmcrypt.*
rm -f /usr/lib/libmhash*
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
</pre>
<p><strong>###安装PHP：</strong></p>
<pre class="wp-code-highlight prettyprint">cd /app/tool/
wget http://cn2.php.net/distributions/php-5.6.16.tar.gz
tar zxf php-5.6.16.tar.gz
cd php-5.6.16
./configure --prefix=/app/soft/php5.6.16 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-zend-multibyte --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-opcache=no
make
make install
cp php.ini-development /app/soft/php5.6.16/lib/php.ini
cp /app/soft/php5.6.16/etc/php-fpm.conf.default /app/soft/php5.6.16/etc/php-fpm.conf
cp -R ./sapi/fpm/php-fpm /app/soft/php5.6.16/sbin/php-fpm
/app/soft/php5.6.16/sbin/php-fpm
lsof-i :9000
</pre>
<pre class="wp-code-highlight prettyprint">yum install -y vim lrzsz netstat
最后关闭SELinux（SELinux是一种安全子系统它能控制程序只能访问特定文件）
vim /etc/selinux/config
修改为：SELINUX=disabled
</pre>
<p>至此LNMP环境已经完美搭建，现在可以开启你的LNMP之旅了~<br />
转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a> 原文地址：<a href="http://www.yunda51.com/1802.html">http://www.yunda51.com/1802.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1806</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mysql show processlist 详解</title>
		<link>https://www.yunda51.com/?p=1751</link>
		<comments>https://www.yunda51.com/?p=1751#comments</comments>
		<pubDate>Thu, 09 Mar 2017 09:55:33 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1751</guid>
		<description><![CDATA[mysql&#62; show processlist; +—–+————-+——————–+ &#124; Id &#124; U<a href="https://www.yunda51.com/?p=1751" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<pre class="wp-code-highlight prettyprint">
    mysql&gt; show processlist;
    +—–+————-+——————–+
    | Id | User | Host | db | Command | Time| State | Info
    +—–+————-+——————–+
    |207|root |192.168.0.2:51621 |mytest | Sleep | 5 | | NULL
    |208|root |192.168.0.2:51622 |mytest | Sleep | 5 | | NULL
    |220|root |192.168.0.2:51676 |mytest |Query | 84 | locked |
    select name,culture,value,type from book where id=1
</pre>
<p>说明各列的含义和用途，</p>
<pre class="wp-code-highlight prettyprint">
  id列:一个标识，你要kill 一个语句的时候很有用。
  user列: 显示当前用户，如果不是root，这个命令就只显示你权限范围内的sql语句。
  host列:显示这个语句是从哪个ip 的哪个端口上发出的。可用来追踪出问题语句的用户。
  db列:显示这个进程目前连接的是哪个数据库。
  command列:显示当前连接的执行的命令，一般就是休眠（sleep），查询（query），连接（connect）。
  time列:此这个状态持续的时间，单位是秒。
  state列:显示使用当前连接的sql语句的状态，很重要的列，后续会有所有的状态的描述，
  请注意，state只是语句执行中的某一个状态，一个sql语句，已查询为例，可能需要经过
  copying to tmp table，Sorting result，Sending data等状态才可以完成。
</pre>
<p>这个命令中最关键的就是state列，mysql列出的状态主要有以下几种：</p>
<pre class="wp-code-highlight prettyprint">
     Checking table
    正在检查数据表（这是自动的）。
    Closing tables
    正在将表中修改的数据刷新到磁盘中，同时正在关闭已经用完的表。这是一个很快的操作，
    如果不是这样的话，就应该确认磁盘空间是否已经满了或者磁盘是否正处于重负中。
    Connect Out
    复制从服务器正在连接主服务器。
    Copying to tmp table on disk
    由于临时结果集大于 tmp_table_size，正在将临时表从内存存储转为磁盘存储以此节省内存。
    Creating tmp table
    正在创建临时表以存放部分查询结果。
    deleting from main table
    服务器正在执行多表删除中的第一部分，刚删除第一个表。
    deleting from reference tables
    服务器正在执行多表删除中的第二部分，正在删除其他表的记录。
    Flushing tables
    正在执行 FLUSH TABLES，等待其他线程关闭数据表。
    Killed
    发送了一个kill请求给某线程，那么这个线程将会检查kill标志位，同时会放弃下一个kill请求。
    MySQL会在每次的主循环中检查kill标志位，不过有些情况下该线程可能会过一小段才能死掉。
    如果该线程程被其他线程锁住了，那么kill请求会在锁释放时马上生效。
    Locked
    被其他查询锁住了。
    Sending data
    正在处理 SELECT 查询的记录，同时正在把结果发送给客户端。
    Sorting for group
    正在为 GROUP BY 做排序。
    Sorting for order
    正在为 ORDER BY 做排序。
    Opening tables
    这个过程应该会很快，除非受到其他因素的干扰。例如，在执 ALTER TABLE 或 LOCK TABLE 语句行完以前，数据表无法被其他线程打开。 正尝试打开一个表。
    Removing duplicates
    正在执行一个 SELECT DISTINCT 方式的查询，但是MySQL无法在前一个阶段优化掉那些重复的记录。因此，MySQL需要再次去掉重复的记录，然后再把结果发送给客户端。
    Reopen table
    获得了对一个表的锁，但是必须在表结构修改之后才能获得这个锁。已经释放锁，关闭数据表，正尝试重新打开数据表。
    Repair by sorting
    修复指令正在排序以创建索引。
    Repair with keycache
    修复指令正在利用索引缓存一个一个地创建新索引。它会比 Repair by sorting 慢些。
    Searching rows for update
    正在讲符合条件的记录找出来以备更新。它必须在 UPDATE 要修改相关的记录之前就完成了。
    Sleeping
    正在等待客户端发送新请求.
    System lock
    正在等待取得一个外部的系统锁。如果当前没有运行多个 mysqld 服务器同时请求同一个表，那么可以通过增加 –skip-external-locking参数来禁止外部系统锁。
    Upgrading lock
    INSERT DELAYED 正在尝试取得一个锁表以插入新记录。
    Updating
    正在搜索匹配的记录，并且修改它们。
    User Lock
    正在等待 GET_LOCK()。
    Waiting for tables
    该线程得到通知，数据表结构已经被修改了，需要重新打开数据表以取得新的结构。然后，为了能的重新打开数据表，必须等到所有其他线程关闭这个表。以下几种情况下会产生这个通知：FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE, 或 OPTIMIZE TABLE。
    waiting for handler insert
    INSERT DELAYED 已经处理完了所有待处理的插入操作，正在等待新的请求。
    大部分状态对应很快的操作，只要有一个线程保持同一个状态好几秒钟，那么可能是有问题发生了，需要检查一下。还有其它的状态没在上面中列出来，不过它们大部分只是在查看服务器是否有存在错误是才用得着。
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1751</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux下添加php的zip模块</title>
		<link>https://www.yunda51.com/?p=1739</link>
		<comments>https://www.yunda51.com/?p=1739#comments</comments>
		<pubDate>Tue, 15 Nov 2016 10:02:19 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zip]]></category>
		<category><![CDATA[zip.so]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1739</guid>
		<description><![CDATA[今天开发做导入excl功能的时候，发现导入的时候一直报错： include(ZipArchive.php): <a href="https://www.yunda51.com/?p=1739" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>今天开发做导入excl功能的时候，发现导入的时候一直报错：</p>
<pre class="wp-code-highlight prettyprint">
include(ZipArchive.php): failed to open stream: No such file or directory。
</pre>
<p>报错如下图：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2016/11/20161115175040.png" target="_blank"><img src="http://www.yunda51.com/wp-content/uploads/2016/11/20161115175040.png" alt="20161115175040" width="1602" height="112" class="alignnone size-full wp-image-1740" /></a><br />
说是没有zip这个模块，于是在网上找了些资料看了看，果真是没有这个模块，于是乎就下载这个包，安装，结果报错了，起初下的zip包的版本是1.10.2，报错之后觉得不以劲，于是就下了1.12.3版本，结果成功了。</p>
<p>之前1.8.10报的错误是： </p>
<pre class="wp-code-highlight prettyprint">
make: *** [php_zip.lo] Error 1
ERROR: `make&#039; failed
</pre>
<p>于是就换了版本再试，下了1.12.3版本：<br />
安装步骤如下：</p>
<pre class="wp-code-highlight prettyprint">
wget http://pecl.php.net/get/zip-1.12.4.tgz
tar zxvf zip-1.12.4.tgz
cd zip-1.12.3
/app/soft/php5.6.16/bin/phpize
./configure --with-php-config=/app/soft/php5.6.16/bin/php-config
make &amp;&amp; make install
</pre>
<p>安装之后查看下zip.so<br />
执行：cd /app/soft/php5.6.16/lib/php/extensions/no-debug-non-zts-20131226/<br />
如图：<a href="http://www.yunda51.com/wp-content/uploads/2016/11/20161115175816.png" target="_blank"><img src="http://www.yunda51.com/wp-content/uploads/2016/11/20161115175816.png" alt="20161115175816" width="1078" height="98" class="alignnone size-full wp-image-1741" /></a><br />
然后修改一下php.ini的配置文件，加上以下的扩展：<br />
extension=zip.so<br />
最后重载php-fpm就可以了 或者 pkill php<br />
到此已经完成，你可以尽情的去开发了，哈哈~~</p>
<p>zip的各种版本可以到以下网站去下载：</p>
<p>http://pecl.php.net/package/zip</p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1739</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP实现数字补零功能的2个函数介绍</title>
		<link>https://www.yunda51.com/?p=1699</link>
		<comments>https://www.yunda51.com/?p=1699#comments</comments>
		<pubDate>Fri, 15 Apr 2016 01:57:18 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[数字]]></category>
		<category><![CDATA[补零]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1699</guid>
		<description><![CDATA[在PHP中至少有两个函数能够帮助我们快速实现数字补零： 首先是PHP str_pad函数： 代码如下: #st<a href="https://www.yunda51.com/?p=1699" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>在PHP中至少有两个函数能够帮助我们快速实现数字补零：<br />
首先是PHP str_pad函数：</p>
<pre class="wp-code-highlight prettyprint">
代码如下:
#str_pad — 使用另一个字符串填充字符串为指定长度
</pre>
<p>顾名思义这个函数是针对字符串，对指定的字符串填补任何其它的字符串<br />
str_pad参数说明：</p>
<pre class="wp-code-highlight prettyprint">
代码如下:
string str_pad ( string $input , int $pad_length [, string $pad_string = &quot; &quot; [, int $pad_type = STR_PAD_RIGHT ]] )
#常用参数说明：str_pad(带填补的字符串,填补后的长度，填补字符串，填补位置)
</pre>
<p>其中填补后的长度必须是个正整数，填补位置有三个选项，<br />
左边：STR_PAD_LEFT<br />
右边：STR_PAD_RIGHT<br />
两端：STR_PAD_BOTH<br />
实例展示：</p>
<pre class="wp-code-highlight prettyprint">
代码如下:
echo str_pad(1,8,&quot;0&quot;,STR_PAD_LEFT);
#结果：00000001
echo str_pad(1,8,&quot;0&quot;,STR_PAD_RIGHT);
#结果：10000000
echo str_pad(1,8,&quot;0&quot;,STR_PAD_BOTH);
#结果：00010000
$pad=str_pad(($number[0][&quot;count(*)&quot;]+1),4,&quot;0&quot;,STR_PAD_LEFT);  //自动补零
</pre>
<p>在上边的例子中值得注意的一个细节是，如果填补的位数是个奇数，例如例三中填补了7个0，右边优先。</p>
<p>下面再看下补零的另外一种方法：<br />
PHP sprintf函数：</p>
<pre class="wp-code-highlight prettyprint">
代码如下:
#sprintf — 返回一个格式化字符串
</pre>
<p>这个函数用起来比较灵活，有待学者们深挖，这里主要讲实现数值左边补零（或者在小数点后补零）的处理方式；<br />
先看左边补零</p>
<pre class="wp-code-highlight prettyprint">
代码如下:
echo sprintf(&quot;%05d&quot;,1);
# %05d的意思：用一个5位数的数字格式化后边的参数，如果不足5位就补零
# 运行结果是00001
</pre>
<p>再看小数点后补零</p>
<pre class="wp-code-highlight prettyprint">
代码如下:
echo sprintf(&quot;%01.3f&quot;,1);
# %01.3f的意思：用一个小数点后最少三位不足三位补零，小数点前最少一位，不足一位补零的浮点数格式化后边的参数
# 运行结果是：1.000
</pre>
<p>另外还可以自己编写一个自定义函数进行处理；<br />
编写代码各有所优也有所劣，大家可以任选适合的；</p>
<p>注：sprintf能够保证不至于误操作把1补成1000000，str_pad可以保证想补啥补啥。</p>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a> 原文地址：<a href="http://www.yunda51.com/1699.html">http://www.yunda51.com/1699.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1699</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
