<?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>admin &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mudbest.com</link>
	<description>行影不离,忘之却步.</description>
	<lastBuildDate>Mon, 28 Apr 2014 04:13:52 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>
	<item>
		<title>哈秋婚庆个人项目案例(组图)</title>
		<link>https://www.mudbest.com/%e5%93%88%e7%a7%8b%e5%a9%9a%e5%ba%86%e4%b8%aa%e4%ba%ba%e9%a1%b9%e7%9b%ae%e6%a1%88%e4%be%8b/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 02 Apr 2011 15:51:18 +0000</pubDate>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[个人项目]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=547</guid>

					<description><![CDATA[由于页面过多，只上传了部分页面。]]></description>
										<content:encoded><![CDATA[<p>由于页面过多，只上传了部分页面。<span id="more-547"></span><br />
<a href="http://www.mudbest.com/547.action/fireshot-capture-007-index-home-hunqing_sk03_com_wedding" rel="attachment wp-att-1363"><img fetchpriority="high" decoding="async" src="http://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-007-index-home-hunqing_sk03_com_wedding1-663x1024.jpg" alt="" title="FireShot-capture-007-index-home-hunqing_sk03_com_wedding" width="640" height="988" class="alignnone size-large wp-image-1363" srcset="https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-007-index-home-hunqing_sk03_com_wedding1-663x1024.jpg 663w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-007-index-home-hunqing_sk03_com_wedding1-278x430.jpg 278w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-007-index-home-hunqing_sk03_com_wedding1.jpg 1345w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p><a href="http://www.mudbest.com/547.action/fireshot-capture-004-zbsy-hunqing_sk03_com_wedding_main_bidding_php1" rel="attachment wp-att-1360"><img decoding="async" src="http://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-004-zbsy-hunqing_sk03_com_wedding_main_bidding_php11-785x1024.jpg" alt="" title="FireShot-capture-004-zbsy-hunqing_sk03_com_wedding_main_bidding_php1" width="640" height="834" class="alignnone size-large wp-image-1360" srcset="https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-004-zbsy-hunqing_sk03_com_wedding_main_bidding_php11-785x1024.jpg 785w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-004-zbsy-hunqing_sk03_com_wedding_main_bidding_php11-329x430.jpg 329w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-004-zbsy-hunqing_sk03_com_wedding_main_bidding_php11.jpg 1345w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p><a href="http://www.mudbest.com/547.action/fireshot-capture-005-zblb-hunqing_sk03_com_wedding_main_biddinglists_php" rel="attachment wp-att-1361"><img decoding="async" src="http://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-005-zblb-hunqing_sk03_com_wedding_main_biddinglists_php1-921x1024.jpg" alt="" title="FireShot-capture-005-zblb-hunqing_sk03_com_wedding_main_biddinglists_php" width="640" height="711" class="alignnone size-large wp-image-1361" srcset="https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-005-zblb-hunqing_sk03_com_wedding_main_biddinglists_php1-921x1024.jpg 921w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-005-zblb-hunqing_sk03_com_wedding_main_biddinglists_php1-386x430.jpg 386w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-005-zblb-hunqing_sk03_com_wedding_main_biddinglists_php1.jpg 1345w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p><a href="http://www.mudbest.com/547.action/fireshot-capture-006-zbinfo-hunqing_sk03_com_wedding_main_bidinginfo_php_id345" rel="attachment wp-att-1362"><img loading="lazy" decoding="async" src="http://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-006-zbinfo-hunqing_sk03_com_wedding_main_bidinginfo_php_id3451-1024x929.jpg" alt="" title="FireShot-capture-006-zbinfo-hunqing_sk03_com_wedding_main_bidinginfo_php_id345" width="640" height="580" class="alignnone size-large wp-image-1362" srcset="https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-006-zbinfo-hunqing_sk03_com_wedding_main_bidinginfo_php_id3451-1024x929.jpg 1024w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-006-zbinfo-hunqing_sk03_com_wedding_main_bidinginfo_php_id3451-473x430.jpg 473w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-006-zbinfo-hunqing_sk03_com_wedding_main_bidinginfo_php_id3451.jpg 1345w" sizes="auto, (max-width: 640px) 100vw, 640px" /></a></p>
<p><a href="http://www.mudbest.com/547.action/fireshot-capture-007-uhome-hunqing_sk03_com_wedding_member_index_php_uidasas" rel="attachment wp-att-1364"><img loading="lazy" decoding="async" src="http://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-007-uhome-hunqing_sk03_com_wedding_member_index_php_uidasas1-687x1024.jpg" alt="" title="FireShot-capture-007-uhome-hunqing_sk03_com_wedding_member_index_php_uidasas" width="640" height="953" class="alignnone size-large wp-image-1364" srcset="https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-007-uhome-hunqing_sk03_com_wedding_member_index_php_uidasas1-687x1024.jpg 687w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-007-uhome-hunqing_sk03_com_wedding_member_index_php_uidasas1-288x430.jpg 288w, https://www.mudbest.com/wp-content/uploads/2011/04/FireShot-capture-007-uhome-hunqing_sk03_com_wedding_member_index_php_uidasas1.jpg 1345w" sizes="auto, (max-width: 640px) 100vw, 640px" /></a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>mysql筛选GROUP BY多个字段组合时的用法</title>
		<link>https://www.mudbest.com/mysql%e7%ad%9b%e9%80%89group-by%e5%a4%9a%e4%b8%aa%e5%ad%97%e6%ae%b5%e7%bb%84%e5%90%88%e6%97%b6%e7%9a%84%e7%94%a8%e6%b3%95/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 02 Apr 2011 06:11:20 +0000</pubDate>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[group]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=539</guid>

					<description><![CDATA[想要得到以下效果： 如果使用group by一个条件的话,得到的结果会少了很多,如何多个条件组合筛选呢 循环的 ... <a title="mysql筛选GROUP BY多个字段组合时的用法" class="read-more" href="https://www.mudbest.com/mysql%e7%ad%9b%e9%80%89group-by%e5%a4%9a%e4%b8%aa%e5%ad%97%e6%ae%b5%e7%bb%84%e5%90%88%e6%97%b6%e7%9a%84%e7%94%a8%e6%b3%95/" aria-label="阅读 mysql筛选GROUP BY多个字段组合时的用法">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>想要得到以下效果：<br />
<a href="http://www.mudbest.com/539.action/mysql-group-by-contact_ws" rel="attachment wp-att-542"><img loading="lazy" decoding="async" src="http://www.mudbest.com/wp-content/uploads/2011/04/mysql-group-by-contact_ws.gif" alt="" title="mysql-group-by-contact_ws" width="470" height="292" class="alignnone size-full wp-image-542" /></a><br />
如果使用group by一个条件的话,得到的结果会少了很多,如何多个条件组合筛选呢</p>
<pre class="brush: plain; title: ; notranslate">
group by fielda,fieldb,fieldc...  
</pre>
<p>循环的时候可以通过判断后一个跟前面一个是否相同来分组，一个示例</p>
<pre class="brush: php; title: ; notranslate">
$result = mysql_query(&quot;SELECT groups,name,goods FROM table GROUP BY groups,name ORDER BY name&quot;);
$arr = array();
$i = 0;
while($row = mysql_fetch_array($result)){
    $arr&#x5B;] = $row;
}

$m = $i - 1;
foreach($arr as $k=&amp;gt;$v){
    if($v&#x5B;$i]&#x5B;'groups'] &lt;&gt; $v&#x5B;$m]&#x5B;'groups']){
        echo '分割符号';
    }
    echo $v&#x5B;'name'],$v&#x5B;'goods'];
}
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Ajax简单异步传输</title>
		<link>https://www.mudbest.com/ajax%e7%ae%80%e5%8d%95%e5%bc%82%e6%ad%a5%e4%bc%a0%e8%be%93/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 04:58:07 +0000</pubDate>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[异步传输]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=535</guid>

					<description><![CDATA[// JavaScript Document // 异步传输 // 2011-04-01 // by hksh ... <a title="Ajax简单异步传输" class="read-more" href="https://www.mudbest.com/ajax%e7%ae%80%e5%8d%95%e5%bc%82%e6%ad%a5%e4%bc%a0%e8%be%93/" aria-label="阅读 Ajax简单异步传输">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
// JavaScript Document
// 异步传输
// 2011-04-01
// by hkshadow 
// QQ 2765237
	
	var RegHtml
	function RegHtmls() {
		if (window.ActiveXObject) {
			RegHtml = new ActiveXObject('Microsoft.XMLHTTP');
			}else if (window.XMLHttpRequest) {
				RegHtml = new XMLHttpRequest();
				}
				}
	
	function BiddingFeed(did,puser,url) {
		RegHtmls();
		RegHtml.open(&quot;GET&quot;,url+puser,true);
		RegHtml.onreadystatechange = function() {Divt(did)};
		RegHtml.send(null);
		}
	
	function Divt(did) {			
			if (RegHtml.readyState == 1)  {
		document.getElementById(did).innerHTML=&quot;loading....&quot;;
		}else if (RegHtml.readyState == 4 &amp;&amp; RegHtml.status == 200 ) {
		document.getElementById(did).innerHTML=RegHtml.responseText;
			}else{
		document.getElementById(did).innerHTML='失去通信.....请刷新';
			}
		}
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>php正则判断大小写</title>
		<link>https://www.mudbest.com/php%e6%ad%a3%e5%88%99%e5%88%a4%e6%96%ad%e5%a4%a7%e5%b0%8f%e5%86%99/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 03:18:19 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[正则]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=530</guid>

					<description><![CDATA[if(isset($userget)){ $userzz = &#34;/^(&#x5B;a-zA-Z])&#038; ... <a title="php正则判断大小写" class="read-more" href="https://www.mudbest.com/php%e6%ad%a3%e5%88%99%e5%88%a4%e6%96%ad%e5%a4%a7%e5%b0%8f%e5%86%99/" aria-label="阅读 php正则判断大小写">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
	if(isset($userget)){
			$userzz = &quot;/^(&#x5B;a-zA-Z])&#x5B;_a-zA-Z0-9]+$|^&#x5B;1-9]&#x5B;_a-zA-Z0-9]+$/&quot;;
			$userzzz = &quot;/^&#x5B;A-Z]+$/&quot;;
			preg_match($userzz, $getuserss, $userarr);  
			preg_match($userzzz, $userarr&#x5B;1], $usera);   
		if ($userget == &quot;&quot;) {   
			echo iconv(&quot;GBK&quot;,&quot;utf-8&quot;,&quot;用户名不能为空&quot;);
		}else 
		if (strlen($getuserss) &lt; 3) {
			echo iconv(&quot;GBK&quot;, &quot;utf-8&quot;, &quot;用户名不能少于3个字符&quot;);
		}else if ($getuserss == $rows&#x5B;'user']) {
				echo iconv(&quot;GBK&quot;, &quot;utf-8&quot;, &quot;用户已存在&quot;);
			}else if ($userarr == true) {   //判断起始大小写
			    if ($usera == true) {
			    		echo iconv(&quot;GBK&quot;, &quot;utf-8&quot;, &quot;起始位不能大写&quot;);
			    }
			}
			else {
				echo iconv(&quot;GBK&quot;,&quot;utf-8&quot;,&quot;用户名格式错误&quot;);
			}
		exit;	
		}
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>php获取前秒分时天</title>
		<link>https://www.mudbest.com/php%e8%8e%b7%e5%8f%96%e5%89%8d%e7%a7%92%e5%88%86%e6%97%b6%e5%a4%a9/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 03:16:21 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[时间前]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=528</guid>

					<description><![CDATA[/** * 获取 几秒前，几分钟前，几小时前，几天前 * by hkshadow * 2011-04-01 * ... <a title="php获取前秒分时天" class="read-more" href="https://www.mudbest.com/php%e8%8e%b7%e5%8f%96%e5%89%8d%e7%a7%92%e5%88%86%e6%97%b6%e5%a4%a9/" aria-label="阅读 php获取前秒分时天">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
/**
 * 获取 几秒前，几分钟前，几小时前，几天前
 * by hkshadow
 * 2011-04-01
 * Enter description here ...
 * @param $val this mktime() or date()
 */
function ToTime($val){
	$nows = date(&quot;Y-m-d H:i:s&quot;,mktime());
	//$nows = date(&quot;Y-m-d H:i:s&quot;,mktime()+8*60*60);
	$nows = strtotime($nows);
	if (strlen($val) &gt;= 11){ 
		$show_time = strtotime($val);
		}else{
			$show_time = $val;
		}
	$overtime = $nows - $show_time;
	if ($overtime &lt; 0 ){
		return $overtime.&quot;秒前&quot;;
	}else if ($overtime &lt; 60){
		return $overtime.&quot;秒前&quot;;
	}else if ($overtime &lt; 3600){
		return ceil($overtime/60).&quot;分钟前&quot;;
	}else if ($overtime &lt; 86400){
		return ceil($overtime/3600).&quot;小时前&quot;;
	}else if ($overtime &lt; 259200) {  //三天前
		return ceil($overtime/86400).&quot;天前&quot;;
	}else{
		return $overtime;
	}
}
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PHP设置页面编码</title>
		<link>https://www.mudbest.com/php%e8%ae%be%e7%bd%ae%e9%a1%b5%e9%9d%a2%e7%bc%96%e7%a0%81/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 02:13:43 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[header]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=523</guid>

					<description><![CDATA[header(&#34;Content-Type:text/html; charset=utf-8&#038;quot ... <a title="PHP设置页面编码" class="read-more" href="https://www.mudbest.com/php%e8%ae%be%e7%bd%ae%e9%a1%b5%e9%9d%a2%e7%bc%96%e7%a0%81/" aria-label="阅读 PHP设置页面编码">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
header(&quot;Content-Type:text/html; charset=utf-8&quot;);
</pre>
<p>关于php的header()函数的介绍如下：</p>
<p>定义和用法<br />
header() 函数向客户端发送原始的 HTTP 报头。<br />
认识到一点很重要，即必须在任何实际的输出被发送之前调用 header() 函数（在 PHP 4 以及更高的<span id="more-523"></span>版本中，您可以使用输出缓存来解决此问题）：</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!-- // 结果出错 // 在调用 header() 之前已存在输出 header('Location: http://www.mudbest.com/');--&gt;
</pre>
<p>语法</p>
<pre class="brush: php; title: ; notranslate">
header(string,replace,http_response_code)
</pre>
<table>
<tbody>
<tr>
<th>参数</th>
<th>描述</th>
</tr>
<tr>
<td>string</td>
<td>必需。规定要发送的报头字符串。</td>
</tr>
<tr>
<td>replace</td>
<td>可选。指示该报头是否替换之前的报头，或添加第二个报头。</p>
<p>默认是 true（替换）。false（允许相同类型的多个报头）。</td>
</tr>
<tr>
<td>http_response_code</td>
<td>可选。把 HTTP 响应代码强制为指定的值。（PHP 4 以及更高版本可用）</td>
</tr>
</tbody>
</table>
<p>提示和注释<br />
注释：从 PHP 4.4 之后，该函数防止一次发送多个报头。这是对头部注入攻击的保护措施。</p>
<p>例子1</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
// Date in the past
header(&quot;Expires: Mon, 26 Jul 1997 05:00:00 GMT&quot;);
header(&quot;Cache-Control: no-cache&quot;);
header(&quot;Pragma: no-cache&quot;);
?&gt;
</pre>
<p>注释：<br />
用户可能会设置一些选项来更改浏览器的默认缓存设置。通过发送上面的报头，您可以覆盖任何这些设置，强制浏览器不进行缓存！</p>
<p>例子 2<br />
提示用户保存一个生成的 PDF 文件（Content-Disposition 报头用于提供一个推荐的文件名，并强制浏览器显示保存对话框）：</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
header(&quot;Content-type:application/pdf&quot;);

// 文件将被称为 downloaded.pdf
header(&quot;Content-Disposition:attachment;filename='downloaded.pdf'&quot;);

// PDF 源在 original.pdf 中
readfile(&quot;original.pdf&quot;);
?&gt;
</pre>
<p>注释：<br />
微软 IE 5.5 存在一个阻止以上机制的 bug。通过升级为 Service Pack 2 或更高的版本，可以解决该 bug。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>header对文本进行下载思路</title>
		<link>https://www.mudbest.com/header%e5%af%b9%e6%96%87%e6%9c%ac%e8%bf%9b%e8%a1%8c%e4%b8%8b%e8%bd%bd%e6%80%9d%e8%b7%af/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 02:13:09 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[header]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=524</guid>

					<description><![CDATA[&#60;?php header(&#34;Content-Type: application/force-d ... <a title="header对文本进行下载思路" class="read-more" href="https://www.mudbest.com/header%e5%af%b9%e6%96%87%e6%9c%ac%e8%bf%9b%e8%a1%8c%e4%b8%8b%e8%bd%bd%e6%80%9d%e8%b7%af/" aria-label="阅读 header对文本进行下载思路">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
&lt;?php 
header(&quot;Content-Type: application/force-download&quot;); 
header(&quot;Content-Disposition: attachment; filename=&quot;.basename($_GET&#x5B;'url'])); 
readfile($filename); 
?&gt; 
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PHP获取当前url路径的函数及服务器变量</title>
		<link>https://www.mudbest.com/php%e8%8e%b7%e5%8f%96%e5%bd%93%e5%89%8durl%e8%b7%af%e5%be%84%e7%9a%84%e5%87%bd%e6%95%b0%e5%8f%8a%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%8f%98%e9%87%8f/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 31 Mar 2011 03:04:30 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SERVER]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=520</guid>

					<description><![CDATA[1，$_SERVER[&#8220;QUERY_STRING&#8221;] 说明：查询(query)的字符串 ... <a title="PHP获取当前url路径的函数及服务器变量" class="read-more" href="https://www.mudbest.com/php%e8%8e%b7%e5%8f%96%e5%bd%93%e5%89%8durl%e8%b7%af%e5%be%84%e7%9a%84%e5%87%bd%e6%95%b0%e5%8f%8a%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%8f%98%e9%87%8f/" aria-label="阅读 PHP获取当前url路径的函数及服务器变量">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>1，$_SERVER[&#8220;QUERY_STRING&#8221;]<br />
说明：查询(query)的字符串</p>
<p>2，$_SERVER[&#8220;REQUEST_URI&#8221;]<br />
说明：访问此页面所需的URI</p>
<p>3，$_SERVER[&#8220;SCRIPT_NAME&#8221;]<br />
说明：包含当前脚本的路径</p>
<p>4，$_SERVER[&#8220;PHP_SELF&#8221;]<br />
说明：当前正在执行脚本的文件名</p>
<p>实例：<br />
1，http://www.mudbest.com/ (直接打开主页)<br />
结果：<br />
$_SERVER[&#8220;QUERY_STRING&#8221;] = &#8220;&#8221;<br />
$_SERVER[&#8220;REQUEST_URI&#8221;] = &#8220;/&#8221;<br />
$_SERVER[&#8220;SCRIPT_NAME&#8221;] = &#8220;/index.php&#8221;<br />
$_SERVER[&#8220;PHP_SELF&#8221;]     = &#8220;/index.php&#8221;</p>
<p>2，http://www.mudbest.com/?p=222<br />
结果：<br />
$_SERVER[&#8220;QUERY_STRING&#8221;] = &#8220;p=222&#8221;<br />
$_SERVER[&#8220;REQUEST_URI&#8221;] = &#8220;/?p=222&#8221;<br />
$_SERVER[&#8220;SCRIPT_NAME&#8221;] = &#8220;/index.php&#8221;<br />
$_SERVER[&#8220;PHP_SELF&#8221;]     = &#8220;/index.php&#8221;</p>
<p>3，http://www.mudbest.com/index.php?p=222&#038;q=biuuu<br />
结果：<br />
$_SERVER[&#8220;QUERY_STRING&#8221;] = &#8220;p=222&#038;q=php&#8221;<br />
$_SERVER[&#8220;REQUEST_URI&#8221;] = &#8220;/index.php?p=222&#038;q=php&#8221;<br />
$_SERVER[&#8220;SCRIPT_NAME&#8221;] = &#8220;/index.php&#8221;<br />
$_SERVER[&#8220;PHP_SELF&#8221;]     = &#8220;/index.php&#8221;<br />
$_SERVER[&#8220;QUERY_STRING&#8221;]获取查询语句，实例中可知，获取<span id="more-520"></span>的是?后面的值<br />
$_SERVER[&#8220;REQUEST_URI&#8221;] 获取http://www.mudbest.com后面的值，包括/<br />
$_SERVER[&#8220;SCRIPT_NAME&#8221;] 获取当前脚本的路径，如：index.php<br />
$_SERVER[&#8220;PHP_SELF&#8221;] 当前正在执行脚本的文件名</p>
<p>当前url：&#8221;http://&#8221;.$_SERVER[&#8216;HTTP_HOST&#8217;].$_SERVER[&#8216;PHP_SELF&#8217;]</p>
<p>总结一下，对于QUERY_STRING，REQUEST_URI，SCRIPT_NAME和PHP_SELF，深入了解将有利于我们在$_SERVER函数中正确调用这四个值。通过实例详解$_SERVER函数中QUERY_STRING，REQUEST_URI，SCRIPT_NAME和PHP_SELF掌握四个变量之间的区别。</p>
<p>uchome系统中处理技巧：</p>
<pre class="brush: php; title: ; notranslate">
//处理REQUEST_URI
if(!isset($_SERVER&#x5B;'REQUEST_URI'])) {  
    $_SERVER&#x5B;'REQUEST_URI'] = $_SERVER&#x5B;'PHP_SELF'];
    if(isset($_SERVER&#x5B;'QUERY_STRING'])) $_SERVER&#x5B;'REQUEST_URI'] .= '?'.$_SERVER&#x5B;'QUERY_STRING'];
}
if($_SERVER&#x5B;'REQUEST_URI']) {
    $temp = urldecode($_SERVER&#x5B;'REQUEST_URI']);
    if(strexists($temp, '&lt;') || strexists($temp, '&quot;')) {
        $_GET = shtmlspecialchars($_GET);//XSS
     }
}
</pre>
<pre class="brush: php; title: ; notranslate">
&lt;?php
echo $_SERVER&#x5B;'DOCUMENT_ROOT'].&quot;&lt;br&gt;&quot;; //获得服务器文档根变量
echo $_SERVER&#x5B;'PHP_SELF'].&quot;&lt;br&gt;&quot;; //获得执行该代码的文件服务器绝对路径的变量
echo __FILE__.&quot;&lt;br&gt;&quot;; //获得文件的文件系统绝对路径的变量
echo dirname(__FILE__); //获得文件所在的文件夹路径的函数
?&gt;
</pre>
<p>//server函数<br />
$_SERVER[&#8220;HTTP_REFERER&#8221;]=http://localhost/lianxi/<br />
$_SERVER[&#8220;HTTP_ACCEPT_LANGUAGE&#8221;]=zh-cn<br />
$_SERVER[&#8220;HTTP_ACCEPT_ENCODING&#8221;]=gzip, deflate<br />
$_SERVER[&#8220;HTTP_USER_AGENT&#8221;]=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727)<br />
$_SERVER[&#8220;HTTP_HOST&#8221;]=localhost<br />
$_SERVER[&#8220;HTTP_CONNECTION&#8221;]=Keep-Alive<br />
$_SERVER[&#8220;PATH&#8221;]=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Adobe\AGL;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\php;C:\php\ext<br />
$_SERVER[&#8220;SystemRoot&#8221;]=C:\WINDOWS<br />
$_SERVER[&#8220;COMSPEC&#8221;]=C:\WINDOWS\system32\cmd.exe<br />
$_SERVER[&#8220;PATHEXT&#8221;]=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH<br />
$_SERVER[&#8220;WINDIR&#8221;]=C:\WINDOWS<br />
$_SERVER[&#8220;SERVER_SIGNATURE&#8221;]=<br />
Apache/2.0.55 (Win32) PHP/5.1.1 Server at localhost Port 80 \\使用的何服务器<br />
$_SERVER[&#8220;SERVER_SOFTWARE&#8221;]=Apache/2.0.55 (Win32) PHP/5.1.1<br />
$_SERVER[&#8220;SERVER_NAME&#8221;]=localhost \\服务器名称<br />
$_SERVER[&#8220;SERVER_ADDR&#8221;]=127.0.0.1<br />
$_SERVER[&#8220;SERVER_PORT&#8221;]=80 \\服务器端口<br />
$_SERVER[&#8220;REMOTE_ADDR&#8221;]=127.0.0.1<br />
$_SERVER[&#8220;DOCUMENT_ROOT&#8221;]=D:/lianxi \\网站的主目录<br />
$_SERVER[&#8220;SERVER_ADMIN&#8221;]=sss@163.com \\安装APACHE时设置的邮箱<br />
$_SERVER[&#8220;SCRIPT_FILENAME&#8221;]=D:/lianxi/lianxi/servervalues.php \\当前的网页的绝对路径，<br />
$_SERVER[&#8220;REMOTE_PORT&#8221;]=1076 \\远程端口<br />
$_SERVER[&#8220;GATEWAY_INTERFACE&#8221;]=CGI/1.1<br />
$_SERVER[&#8220;SERVER_PROTOCOL&#8221;]=HTTP/1.1<br />
$_SERVER[&#8220;REQUEST_METHOD&#8221;]=GET<br />
$_SERVER[&#8220;QUERY_STRING&#8221;]=\\获取？号后面的内容<br />
$_SERVER[&#8220;REQUEST_URI&#8221;]=例子：/lianxi/servervalues.php?a=1&#038;b=2<br />
$_SERVER[&#8220;SCRIPT_NAME&#8221;]=例子：/lianxi/servervalues.php<br />
$_SERVER[&#8220;PHP_SELF&#8221;]=/lianxi/servervalues.php \\返回当前网页的相对路径.<br />
$_SERVER[&#8220;REQUEST_TIME&#8221;]=1179190013 \\运行时间 单位为十万分之一毫秒<br />
$_SERVER[&#8220;argv&#8221;]=Array<br />
$_SERVER[&#8220;argc&#8221;]=0<br />
1，$_SERVER[&#8220;QUERY_STRING&#8221;]<br />
说明：查询(query)的字符串<br />
2，$_SERVER[&#8220;REQUEST_URI&#8221;]<br />
说明：访问此页面所需的URI<br />
3，$_SERVER[&#8220;SCRIPT_NAME&#8221;]<br />
说明：包含当前脚本的路径<br />
4，$_SERVER[&#8220;PHP_SELF&#8221;]<br />
说明：当前正在执行脚本的文件名<br />
实例：<br />
1，http://www.mudbest.com/ (直接打开主页)<br />
结果：<br />
$_SERVER[&#8220;QUERY_STRING&#8221;] = “”<br />
$_SERVER[&#8220;REQUEST_URI&#8221;] = “/”<br />
$_SERVER[&#8220;SCRIPT_NAME&#8221;] = “/index.php”<br />
$_SERVER[&#8220;PHP_SELF&#8221;] = “/index.php”<br />
2，http://www.mudbest.com/?p=222 (附带查询)<br />
结果：<br />
$_SERVER[&#8220;QUERY_STRING&#8221;] = “p=222″<br />
$_SERVER[&#8220;REQUEST_URI&#8221;] = “/?p=222″<br />
$_SERVER[&#8220;SCRIPT_NAME&#8221;] = “/index.php”<br />
$_SERVER[&#8220;PHP_SELF&#8221;] = “/index.php”<br />
3，http://www.mudbest.com/index.php?p=222&#038;q=php<br />
结果：<br />
$_SERVER[&#8220;QUERY_STRING&#8221;] = “p=222&#038;q=php”<br />
$_SERVER[&#8220;REQUEST_URI&#8221;] = “/index.php?p=222&#038;q=php”<br />
$_SERVER[&#8220;SCRIPT_NAME&#8221;] = “/index.php”<br />
$_SERVER[&#8220;PHP_SELF&#8221;] = “/index.php”<br />
$_SERVER[&#8220;QUERY_STRING&#8221;]获取查询语句，实例中可知，获取的是?后面的值<br />
$_SERVER[&#8220;REQUEST_URI&#8221;] 获取http://www.mudbest.com后面的值，包括/<br />
$_SERVER[&#8220;SCRIPT_NAME&#8221;] 获取当前脚本的路径，如：index.php<br />
$_SERVER[&#8220;PHP_SELF&#8221;] 当前正在执行脚本的文件名</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
* __FILE__ ,
* getcwd(),
$_SERVER&#x5B;&quot;REQUEST_URI&quot;],
$_SERVER&#x5B;&quot;SCRIPT_NAME&quot;],
$_SERVER&#x5B;&quot;PHP_SELF&quot;],
$_SERVER&#x5B;&quot;SCRIPT_FILENAME&quot;],
来观察一下这些变量或函数的异同.
假设有一个请求地址为: http://localhost:8080/test.php/age=20
而test.php 的完整路径是: D:/server/www/example/test.php
1) getcwd()
将得到浏览器请求的页面文件所在的目录. 即test.php 文件所在的目录: D:/server/www/example/ ,
如果在test.php 执行了 require 或 include 语句, 比如 inculde(”test_dir/test2.php”),
那么在 test2.php 里 getcwd()函数 返回的也将是 test.php 所在的目录.
2) __FILE__
一个魔术变量, 用它将得到 __FILE__ 变量所在文件的完整路径,
比如: test.php 里 __FILE__ 将得到 D:/server/www/example/test.php ,
test_dir/test2.php 里的 __FILE__ 将得到 D:/server/www/example/test_dir/test2.php

3) $_SERVER&#x5B;&quot;SCRIPT_FILENAME&quot;]
将得到浏览器请求的页面文件的完整路径.
test.php 和 test_dir/test2.php 里用 $_SERVER&#x5B;&quot;SCRIPT_NAME&quot;] 都将得到 D:/server/www/example/test.php.

4) $_SERVER&#x5B;&quot;SCRIPT_NAME&quot;]
将得到浏览器请求的页面文件的文件名,注意: 与 $_SERVER&#x5B;&quot;SCRIPT_NAME&quot;] 不同, 此变量只得到文件名而不包含路径,
在test.php 与 test_dir/test2.php 用$_SERVER&#x5B;&quot;SCRIPT_NAME&quot;] 得到的都将是 test.php.
当然, 在test.php 与 test_dir/test2.php 执行 basename($_SERVER&#x5B;&quot;SCRIPT_FILENAME&quot;]) 与 $_SERVER&#x5B;&quot;SCRIPT_NAME&quot;] 相同.
执行 在test.php 与 test_dir/test2.php 执行 realpath(”test.php”) 得到的结果与 $_SERVER&#x5B;&quot;SCRIPT_FILENAME&quot;] 相同.

5) $_SERVER&#x5B;&quot;PHP_SELF&quot;]
将得到浏览器请求页面的文件名, 并剥掉问号 ? 后的内容, 注意:不包含路径,
比如在客户端里请求 http://localhost:8080/test.php?age=20&amp;name=Tom,
那么test.php 和 test_dir/test2.php 的 $_SERVER&#x5B;&quot;PHP_SELF&quot;] 都将得到 “test.php”。“age=20&amp;name=Tom”被剥掉。
而如果客户端里请求 http://localhost:8080/test.php/age=20&amp;name=Tom,
那么test.php 和 test_dir/test2.php 的 $_SERVER&#x5B;&quot;PHP_SELF&quot;] 都将得到 “test.php/age=20&amp;name=Tom”。

6) $_SERVER&#x5B;&quot;REQUEST_URI&quot;]
将得到浏览器请求页面的文件名, 以及文件名之后的所有内容(注意: 井号 # 之后的内容将被略去),
比如在客户端里请求 http://localhost:8080/test.php?age=20&amp;name=Tom,
那么test.php 和 test_dir/test2.php 的 $_SERVER&#x5B;&quot;REUEST_URI&quot;] 都将得到 “test.php”。“age=20&amp;name=Tom”被剥掉。
而如果客户端里请求 http://localhost:8080/test.php/age=20&amp;name=Tom,
那么test.php 和 test_dir/test2.php 的 $_SERVER&#x5B;&quot;REQUEST_URI&quot;] 都将得到 “test.php/age=20&amp;name=Tom”。
*/

// test.php:
echo “test1.php variables &lt;br /&gt;”;
echo “getcwd: “, getcwd(), “&lt;br /&gt;”;
echo “__FILE__: “, __FILE__, “&lt;br /&gt;”;
echo “REQUEST_URI: “, $_SERVER&#x5B;&quot;REQUEST_URI&quot;], “&lt;br /&gt;”;
echo “SCRIPT_NAME: “, $_SERVER&#x5B;&quot;SCRIPT_NAME&quot;], “&lt;br /&gt;”;
echo “PHP_SELF: “, $_SERVER&#x5B;&quot;PHP_SELF&quot;], “&lt;br /&gt;”;
echo “SCRIPT_FILENAME “, $_SERVER&#x5B;&quot;SCRIPT_FILENAME&quot;] , “&lt;br /&gt;”;

// 把 test2.php 包含进来, 在 test2.php 里输出上面的变量,看有什么不同:
include_once(”test2/test2.php”);
?&gt;
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>mysql随机查询</title>
		<link>https://www.mudbest.com/mysql%e9%9a%8f%e6%9c%ba%e6%9f%a5%e8%af%a2rand/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 30 Mar 2011 09:40:52 +0000</pubDate>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[rand]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=517</guid>

					<description><![CDATA[最近无事，翻了一下以前的博客，发现部分文章现在看起来确实有很大的差异，对于这篇mysql随机查询的文章，现在看 ... <a title="mysql随机查询" class="read-more" href="https://www.mudbest.com/mysql%e9%9a%8f%e6%9c%ba%e6%9f%a5%e8%af%a2rand/" aria-label="阅读 mysql随机查询">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>最近无事，翻了一下以前的博客，发现部分文章现在看起来确实有很大的差异，对于这篇mysql随机查询的文章，现在看起来，问题的确存在。</p>
<p>举个例子，要从tbl_consult表中随机提取一条记录，大家一般的写法就是：<span id="more-517"></span></p>
<pre class="brush: sql; title: ; notranslate">
select * from tbl_consult order by rand() limit 1;
</pre>
<p>执行之后用mysql slow query log看下，发现全表扫了2次，如果这个量非常大，那这说明了问题确实存在。</p>
<p>在官方手册里有这样说过，在order by从句里面不能使用rand()函数，因为这样会导致数据列被多次扫描，意思应该明白了吧，就是说rand()查询的时候会在全表里搜索多次，直到你取到结果数。</p>
<p>有集中查询方法，做一下对比。</p>
<p>1、采用JOIN，查询max(id) * rand()来随机获取数据</p>
<pre class="brush: sql; title: ; notranslate">
SELECT * 
FROM tbl_consult AS t1 JOIN (select round(rand() * (select max(id) FROM tbl_consult)) AS id) AS t2 
WHERE t1.id &gt;= t2.id 
ORDER BY t1.id ASC LIMIT 1; 
</pre>
<p>但是这样会产生连续的5条记录。解决办法只能是每次查询一条，查询5次。即便如此也值得，因为15万条的表，查询只需要0.01秒不到。</p>
<p>2、下面这句在mysql论坛上人用到</p>
<pre class="brush: sql; title: ; notranslate">
SELECT * 
FROM tbl_consult 
WHERE id &gt;= (select floor( max(id) * rand()) FROM tbl_consult ) 
ORDER BY id LIMIT 1;
</pre>
<p>执行上面这句发现还是会大量扫描，也不推荐。</p>
<p>3、稍微的改一下之后</p>
<pre class="brush: sql; title: ; notranslate">
SELECT * FROM tbl_consult 
WHERE id &gt;= (select floor(RAND() * (select max(id) FROM tbl_consult)))  
ORDER BY id LIMIT 1; 
</pre>
<p>最后，再把语句完善一下，加上MIN(id)的判断。我在最开始测试的时候，就是因为没有加上MIN(id)的判断，结果有一半的时间总是查询到表中的前面几行。</p>
<p>4、完整查询语句是</p>
<pre class="brush: sql; title: ; notranslate">
SELECT * FROM tbl_consult 
WHERE id &gt;= (select floor( RAND() * ((select max(id) FROM tbl_consult ) - (select min(id) FROM tbl_consult)) + (select min(id) FROM tbl_consult)))  
ORDER BY id LIMIT 1; 
</pre>
<p>5、再调整一下</p>
<pre class="brush: sql; title: ; notranslate">
SELECT * 
FROM tbl_consult AS t1 JOIN (select ROUND(RAND() * ((select MAX(id) FROM tbl_consult)-(select MIN(id) FROM tbl_consult))+(select MIN(id) FROM tbl_consult)) AS id) AS t2 
WHERE t1.id &gt;= t2.id 
ORDER BY t1.id LIMIT 1;
</pre>
<p>看来采用JOIN的语法比直接在WHERE中使用函数效率还要高很多。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PHP时间格式函数</title>
		<link>https://www.mudbest.com/%e6%97%b6%e9%97%b4%e6%a0%bc%e5%bc%8f%e5%87%bd%e6%95%b0/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 25 Mar 2011 03:15:15 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[时间戳]]></category>
		<category><![CDATA[时间格式]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=513</guid>

					<description><![CDATA[/** * 时间格式函数 * by hkshadow * Enter description here ... ... <a title="PHP时间格式函数" class="read-more" href="https://www.mudbest.com/%e6%97%b6%e9%97%b4%e6%a0%bc%e5%bc%8f%e5%87%bd%e6%95%b0/" aria-label="阅读 PHP时间格式函数">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
/**
 * 时间格式函数
 * by hkshadow
 * Enter description here ...
 * @param  $type 1 年月日   2 年月日小时分钟秒        3 年月
 * @param  $val  mktime()
 */
function MkTimeToDate($type,$val){
	if ($type == '1'){
		$dtime = date(&quot;Y-m-d&quot;,$val);
	}else if ($type == '2'){
		$dtime = date(&quot;Y-m-d H:i:s&quot;,$val);
	}else if ($type == '3'){
		$dtime = date(&quot;Y-m&quot;,$val);
	}
	return $dtime;
}
</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
