<?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/"
	>

<channel>
	<title>PHP网站开发-PHP教程-LeapSoul.CN</title>
	<atom:link href="http://www.leapsoul.cn/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.leapsoul.cn</link>
	<description>David's blog - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站</description>
	<pubDate>Fri, 20 Aug 2010 09:31:27 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP使用xpath解析XML实例教程</title>
		<link>http://www.leapsoul.cn/?p=975</link>
		<comments>http://www.leapsoul.cn/?p=975#comments</comments>
		<pubDate>Fri, 20 Aug 2010 09:25:28 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[PHP XML实例]]></category>

		<category><![CDATA[PHP XML解析]]></category>

		<category><![CDATA[PHP Xpath教程]]></category>

		<category><![CDATA[Xpath实例]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=975</guid>
		<description><![CDATA[本文详解PHP解析XML文件时Xpath的使用教程，通过Xpath实例介绍Xpath语法、Xpath路径表达式的具体应用，不可多得的PHP Xpath入门教程。]]></description>
			<content:encoded><![CDATA[<p>　　XML文件在PHP网站开发的轻量级应用中使用非常广泛，而PHP解析和读取XML文件的方式有很多种，比如JS DOM、SimpleXml、Xpath等方式解析XML文件，今天来讲讲在PHP中使用Xpath解析XML的实例，同时通过Xpath解析XML的实例来介绍部分基础的Xpath语法。</p>
<p>　　<strong>Xpath是什么？</strong></p>
<p>　　Xapth主要用来在XML文档中查询信息的工具，通过使用路径表达式可以解析XML文件，读取XML文件中的数据。<span id="more-975"></span></p>
<p>　　<strong>PHP解析XML推荐教程</strong></p>
<p>　　<a href="http://www.leapsoul.cn/?p=205">PHP4和PHP5版本下解析XML文档的操作方法</a></p>
<p>　　<strong>需要PHP解析的XML文档</strong></p>
<div class="codecolorer-container xml mac-classic" style="overflow:auto;white-space:nowrap;width:550px;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="xml codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;gbk&quot;</span><span class="re2">?&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;LeapsoulXML<span class="re2">&gt;</span></span></span> &nbsp;<br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;LeapsoulInfo<span class="re2">&gt;</span></span></span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>PHP网站开发-PHP教程-Leapsoul.cn<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;website<span class="re2">&gt;</span></span></span>http://www.leapsoul.cn<span class="sc3"><span class="re1">&lt;/website<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/LeapsoulInfo<span class="re2">&gt;</span></span></span><br />
<br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;LeapsoulInfo<span class="re2">&gt;</span></span></span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;keywords<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;keyword</span> <span class="re0">keyid</span>=<span class="st0">'1'</span><span class="re2">&gt;</span></span>PHP网站开发<span class="sc3"><span class="re1">&lt;/keyword<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;keyword</span> <span class="re0">keyid</span>=<span class="st0">'2'</span><span class="re2">&gt;</span></span>PHP教程<span class="sc3"><span class="re1">&lt;/keyword<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;keyword</span> <span class="re0">keyid</span>=<span class="st0">'3'</span><span class="re2">&gt;</span></span>PHP<span class="sc3"><span class="re1">&lt;/keyword<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/keywords<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;seo<span class="re2">&gt;</span></span></span>SEO<span class="sc3"><span class="re1">&lt;/seo<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/LeapsoulInfo<span class="re2">&gt;</span></span></span><br />
<br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;WebInfo<span class="re2">&gt;</span></span></span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>PHP网站开发<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;website<span class="re2">&gt;</span></span></span>http://www.leapsoul.cn<span class="sc3"><span class="re1">&lt;/website<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/WebInfo<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/LeapsoulXML<span class="re2">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>　　<strong>Xpath语法教程</strong></p>
<p>　　<em>/</em>表示从XML文件中的根节点开始解析</p>
<p>　　<em>//</em>表示在XML文件中匹配已选择的当前节点，且不考虑其位置关系（类似于SQL中模糊查询）</p>
<p>　　<em>.</em><span> </span>表示选取当前节点</p>
<p>　　<em>..</em>表示选取当前节点的父节点</p>
<p>　　<em>@</em>表示匹配具体的节点或属性</p>
<p>　　<strong>PHP解析XML实例第一步</strong></p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$xml</span> <span class="sy0">=</span> simplexml_load_file<span class="br0">&#40;</span><span class="st_h">'leapsoulcn.xml'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p><strong>说明</strong>：使用PHP SimpleXML载入需要解析的XML文档，SimpleXML默认PHP5支持。</p>
<p>　　<strong>PHP解析XML Xpath实例一：</strong></p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$xml</span><span class="sy0">-&gt;</span><span class="me1">xpath</span><span class="br0">&#40;</span><span class="st_h">'LeapsoulInfo'</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re0">$value</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$value</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>说明</strong>：在这个Xpath实例中通过Xpath查询指定节点，以数组形式返回其所有的子节点，并通过PHP的print_r函数打印出最终的数组结构。</p>
<p>　　<strong>PHP解析XML Xpath实例二</strong></p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$xml</span><span class="sy0">-&gt;</span><span class="me1">xpath</span><span class="br0">&#40;</span><span class="st_h">'LeapsoulInfo/name'</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re0">$value</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$value</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>说明</strong>：在这个Xpath实例中通过Xpath路径表达式的方式指定需要Xapth查询的某个特定子节点，以数组形式返回这个子节点的元素。</p>
<p>　　<strong>PHP解析XML Xpath实例三</strong></p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$xml</span><span class="sy0">-&gt;</span><span class="me1">xpath</span><span class="br0">&#40;</span><span class="st_h">'//name'</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re0">$value</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$value</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>说明</strong>：在这个Xpath实例中通过使用//表示使用Xpath查询XML文件中所有name节点的元素，与上一个Xpath实例的区别在于name没有位置关系。</p>
<p>　　<strong>PHP解析XML Xpath实例四</strong></p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$xml</span><span class="sy0">-&gt;</span><span class="me1">xpath</span><span class="br0">&#40;</span><span class="st_h">'LeapsoulInfo//name'</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re0">$value</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$value</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>说明</strong>：PHP解析XML文件中指定节点下的某个子节点，以数组形式返回其所有子节点，忽略指定的这个子节点在LeapsoulInfoXML中的位置关系。</p>
<p>　　<strong>PHP解析XML Xpath实例五</strong></p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$xml</span><span class="sy0">-&gt;</span><span class="me1">xpath</span><span class="br0">&#40;</span><span class="st0">&quot;//name/keywords/keyword[@keyid='1']&quot;</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re0">$value</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$value</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>说明</strong>：在需要PHP解析的XML文件中通过Xpath查找keyid=1的元素，以数组形式返回。</p>
<p>　　OK，上述几个PHP Xpath实例教程是PHP解析XML文件最基础的方法，通过合理使用Xpath路径表达式可以进行复杂的XML查询和解析，使用起来感觉和SQL一样方便。</p>
<p>　　<strong>注</strong>：<a title="PHP网站开发-PHP教程-leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=975</wfw:commentRss>
		</item>
		<item>
		<title>PHP字符串函数教程:PHP字符串分割函数处理</title>
		<link>http://www.leapsoul.cn/?p=969</link>
		<comments>http://www.leapsoul.cn/?p=969#comments</comments>
		<pubDate>Tue, 27 Jul 2010 07:43:40 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[PHP字符串函数]]></category>

		<category><![CDATA[PHP字符串分割]]></category>

		<category><![CDATA[PHP字符串处理]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=969</guid>
		<description><![CDATA[详解PHP字符串分割函数explode、strtok、str_split拆分字符串的区别，通过PHP代码介绍如何使用PHP字符串分割函数处理字符串，实用的PHP字符串函数入门教程。]]></description>
			<content:encoded><![CDATA[<p>　　PHP字符串函数在PHP网站开发中广泛使用，比如使用PHP字符串函数对字符串分割、截取、匹配、替换等处理。PHP字符串函数对于PHP入门学习者来说必不可少，本文将主要介绍PHP字符串分割函数处理心得，开启PHP字符串函数入门学习教程之旅。<span id="more-969"></span></p>
<p>　　<strong>常用的PHP字符串分割函数</strong></p>
<p>　　常用的PHP分割字符串函数主要有explode、strtok、str_split，主要用来拆分字符串，并以数组或字符串形式返回，与这三个PHP字符串分隔函数相对应的，以分隔符连接拆分字符串的PHP字符串函数有implode、join，效果和explode正好相反，另外join函数是implode函数的别名。</p>
<p>　　<strong>PHP字符串分割函数explode处理说明</strong></p>
<p>　　函数原型：array explode(string separator,string input);</p>
<p>　　explode函数应用非常广泛，其主要作用是对规定的字符串以设定的分隔符进行拆分，并以数组形式返回。其常使用在分割文件名以判断文件类型、切割用户Email等场合。</p>
<p>　　<em>PHP字符串分割函数explode处理实例</em></p>
<p>　　1、获取文件扩展名</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$fileName</span> <span class="sy0">=</span> <span class="st0">&quot;leapsoulcn.jpg&quot;</span><span class="sy0">;</span><br />
<span class="re0">$str</span> <span class="sy0">=</span> <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span><span class="sy0">,</span><span class="re0">$fileName</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$str</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>我们知道在<a title="PHP文件上传教程" href="http://www.leapsoul.cn/?p=246">PHP文件上传功能</a>中，判断上传文件名是否合法的最基本方法是判断扩展名是否合法，这时候就需要使用PHP字符串函数explode对文件名进行分割处理。在上述代码中explode函数以.为分隔符，对文件名进行分割。输入结果如下</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">Array ( [0] =&gt; leapsoulcn [1] =&gt; jpg )</div></td></tr></tbody></table></div>
<p>2、获取用户Email域名信息</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$emailInfo</span> <span class="sy0">=</span> <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;@&quot;</span><span class="sy0">,</span><span class="re0">$email</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>3、获取用户访问的URL具体文件名</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$url</span> <span class="sy0">=</span> <span class="st0">&quot;http://www.leapsoul.cn/index.php&quot;</span><span class="sy0">;</span><br />
<span class="re0">$urlFileName</span> <span class="sy0">=</span> <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;/&quot;</span><span class="sy0">,</span><span class="re0">$url</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>输出结果</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">Array ( [0] =&gt; http: [1] =&gt; [2] =&gt; www.leapsoul.cn [3] =&gt; index.php )</div></td></tr></tbody></table></div>
<p>　　<strong>PHP字符串分割函数strtok处理说明</strong></p>
<p>　　函数原型：string strtok(string input,string separator);</p>
<p>　　PHP字符串函数strtok与explode函数的区别在于，strtok函数在分割字符串后可记住分割后新字符串在原字符串中的位置以便于继续分割，返回类型为string。如果想要重新分割，只要将字符串重新传给strtok即可。</p>
<p>　　<em>PHP字符串分割函数strtok处理实例</em></p>
<p>　　分割用户访问的URL地址</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$url</span> <span class="sy0">=</span> <span class="st0">&quot;http://www.leapsoul.cn/index.php&quot;</span><span class="sy0">;</span><br />
<span class="re0">$urlFileName</span> <span class="sy0">=</span> <a href="http://www.php.net/strtok"><span class="kw3">strtok</span></a><span class="br0">&#40;</span><span class="re0">$url</span><span class="sy0">,</span><span class="st0">&quot;/&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$urlFileName</span><span class="sy0">.</span><span class="st0">&quot;&lt;br/&gt;&quot;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">while</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$urlFileName</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$urlFileName</span> <span class="sy0">=</span> <a href="http://www.php.net/strtok"><span class="kw3">strtok</span></a><span class="br0">&#40;</span><span class="st0">&quot;/&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$urlFileName</span><span class="sy0">.</span><span class="st0">&quot;&lt;br/&gt;&quot;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>输出结果</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">http:<br />
www.leapsoul.cn<br />
index.php</div></td></tr></tbody></table></div>
<p>　　<strong>PHP字符串分割函数str_split处理说明</strong></p>
<p>　　函数原型：array str_split(string,length)</p>
<p>　　length默认为1，如果length小于1，则返回false，如果length大于字符串原有长度，则返回整个字符串作为数组元素。</p>
<p>　　PHP字符串函数str_split与explode函数的区别在于str_split是以长度来分割字符串而不是以分隔符来分割，有点类似于substr字符串函数的处理方式。</p>
<p>　　<strong>PHP字符串分割函数总结</strong></p>
<p>　　相对来说PHP字符串分割函数explode应用比较广泛，结合PHP字符串匹配、截取函数可以做出很多应用，我的PHP文件上传功能和<a title="wordpress天气预报插件" href="http://www.leapsoul.cn/?p=181">天气预报插件</a>都应用到了PHP字符串函数的处理。</p>
<p>　　<strong>注</strong>：<a title="PHP网站开发-PHP教程-leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=969</wfw:commentRss>
		</item>
		<item>
		<title>使用zend studio配置Xdebug调试PHP教程</title>
		<link>http://www.leapsoul.cn/?p=958</link>
		<comments>http://www.leapsoul.cn/?p=958#comments</comments>
		<pubDate>Fri, 23 Jul 2010 15:22:39 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[我的原创]]></category>

		<category><![CDATA[xdebug使用]]></category>

		<category><![CDATA[xdebug教程]]></category>

		<category><![CDATA[zend studio xdebug]]></category>

		<category><![CDATA[zend studio调试]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=958</guid>
		<description><![CDATA[以图文教程形式介绍如何使用zend studio配置Xdebug来调试PHP程序，涉及Xdebug配置细节以及zend studio调试PHP的具体使用方法，适合PHP入门学习者的zend studio xdebug调试入门教程。]]></description>
			<content:encoded><![CDATA[<p>　　之前我介绍了<a href="http://www.leapsoul.cn/?p=791">PHP开发工具Zend Studio7入门使用教程</a>，其实使用zend studio调试PHP非常方便，zend studio默认支持调试工具zend debugger也允许使用第三方调试工具，今天以PHP教程形式分享如何使用zend studio配置Xdebug来调试PHP程序。</p>
<p>　　使用Xdebug在zend studio中调试PHP源码之前，请务必安装配置Xdebug，这是基础教程，可参考<a href="http://www.leapsoul.cn/?p=935">PHP调试工具Xdebug安装配置教程</a>一文，Xdebug结合zend studio在配置方面还是有点区别的。<span id="more-958"></span></p>
<p>　　在zend studio中使用Xdebug调试PHP源码之前，需要针对zend studio对Xdebug进行配置，否则无法使用Xdebug调试PHP。</p>
<p>　　<strong>针对zend studio配置Xdebug的教程</strong></p>
<p>　　打开PHP安装目录（<a title="PHP环境配置教程" href="http://www.leapsoul.cn/?tag=php环境配置">如何安装配置PHP</a>？）下的PHP.INI配置文件，我的是C:\PHP目录，找到Xdebug配置信息，在此基础上添加如下Xdebug配置信息</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">xdebug.remote_enable=true     //Xdebug允许远程IDE连接<br />
xdebug.remote_host=127.0.0.1   //允许连接的zend studio的IP地址<br />
xdebug.remote_port=9000       //反向连接zend studio使用的端口<br />
xdebug.remote_handler=dbgp    //用于zend studio远程调试的应用层通信协议</div></td></tr></tbody></table></div>
<p><strong>重要说明</strong>：这里容易忽视的一个问题是xdebug.remote_host信息的配置，如果你使用的是局域网或无线路由器，将xdebug.remote_host配置为127.0.0.1是无用的，会导致无法使用zend studio调试PHP，zend studio的单步调试按钮也无效！必须将xdebug.remote_host配置为zend studio安装机器的实际地址，IP地址可以通过ipconfig查看，由于我使用的是无线路由器，所以我将xdebug.remote_host配置为192.168.1.100。</p>
<p>　　最后重启apache服务器。</p>
<p>　　Ok，下面我们就可以使用Xdebug在zend studio中进行调试工作了。</p>
<p>　　由于zend studio默认支持调试PHP的工具是zend debugger，所以首先需要将zend studio PHP Debug选项配置为Xdebug，才能使用Xdebug。</p>
<p>　　<strong>zend studio使用Xdebug调试PHP步骤一</strong></p>
<p>　　打开zend studio7，选择菜单Project-&gt;Properties，然后在弹出界面中选择左侧PHP Debug选项，如图<br />
<div id="attachment_960" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-studio-xdebug-config.gif"><img class="size-full wp-image-960" title="在zend studio中配置使用Xdebug调试PHP教程" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-studio-xdebug-config.gif" alt="在zend studio中配置使用Xdebug调试PHP教程" width="480" height="332" /></a><p class="wp-caption-text">在zend studio中配置使用Xdebug调试PHP教程</p></div></p>
<p>　　勾选 Enable project specific settings选项，并选择PHP Debugger选项中的Xdebug选项，最后点击确定即可。</p>
<p>　　<strong>说明</strong>：在使用zend studio调试PHP时，有时会出现一个问题，即zend studio调试PHP文件时没有使用Xdebug进行调试，可通过点击左侧上方的项目窗口选择具体的项目或项目文件，右击选择Properties选项进行配置，界面和上图一样。</p>
<p>　　<strong>在zend studio中使用Xdebug调试PHP源码</strong></p>
<p>　　使用zend studio调试PHP，主要通过Debug As菜单，共有三种选择PHP Script、PHP Web Page、PHP Unit Test，此处选择PHP Web Page，由于可能存在同一PHP文件之前使用zend studio调试PHP时并没有选择使用Xdebug，需要清除旧的调试文件，可以通过Debug Configurations菜单清除上述三种zend studio调试方式中的文件，此处选择的是PHP Web Page，所以只要将此项中的文件清除即可。</p>
<p>　　Debug Configurations可通过三种方式进入：1、右击需要调试的PHP文件，选择Debug As或者打开调试的PHP文件；2、选择菜单栏上Run菜单下的Debug As进入；3、点击菜单栏Run菜单下方小蜘蛛图标旁的向下箭头选择Debug Configurations。</p>
<p>　　Debug Configurations配置完毕后，可打开需要使用zend studio调试的PHP文件选择Debug As中的PHP Web Page选项，核对好Launch Url后点击Ok即可调试，Xdebug在zend studio中调试PHP文件的画面如图<br />
<div id="attachment_963" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-studio-xdebug.gif"><img class="size-full wp-image-963" title="在zend-studio中使用xdebug调试PHP教程" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-studio-xdebug.gif" alt="在zend-studio中使用xdebug调试PHP教程" width="480" height="160" /></a><p class="wp-caption-text">在zend-studio中使用xdebug调试PHP教程</p></div></p>
<p>　　如图你可以通过单步调试(F5)对PHP文件进行调试，只要Xdebug配置正确，在调试代码窗口中会出现选中的淡绿色背景代码，否则单步调试(F5)功能是失效的。</p>
<p>　　最后你可以在D:\PHPWeb\xdebug\trace和D:\PHPWeb\xdebug\profiler目录下看到zend studio调试PHP文件时Xdebug输出的调试信息文件cachegrind.out.*和trace.*.xt。</p>
<p>　　至此使用zend studio配置Xdebug调试PHP源码的基础教程就介绍完了，今后还将介绍更多zend studio调试PHP源码的PHP教程。</p>
<p>　　<strong>注</strong>：<a title="leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=958</wfw:commentRss>
		</item>
		<item>
		<title>PHP网站开发教程网访问不稳定声明</title>
		<link>http://www.leapsoul.cn/?p=952</link>
		<comments>http://www.leapsoul.cn/?p=952#comments</comments>
		<pubDate>Thu, 22 Jul 2010 02:55:26 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[生活杂谈]]></category>

		<category><![CDATA[网站声明]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=952</guid>
		<description><![CDATA[　　最近两日PHP网站开发教程网连续发生凌晨0点至9点左右无法访问的情况，原因为虚拟主机提供商服务器不稳定造成，我已致电虚拟主机服务商务必保持PHP服务器空间的稳定，特此向访问网站的各位朋友表达歉意，感谢您对网站的支持！谢谢！
　　注：PHP网站开发教程-leapsoul.cn版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。
]]></description>
			<content:encoded><![CDATA[<p>　　最近两日<a href="http://www.leapsoul.cn" title="PHP网站开发-PHP教程">PHP网站开发教程网</a>连续发生凌晨0点至9点左右无法访问的情况，原因为虚拟主机提供商服务器不稳定造成，我已致电虚拟主机服务商务必保持PHP服务器空间的稳定，特此向访问网站的各位朋友表达歉意，感谢您对网站的支持！谢谢！<span id="more-952"></span></p>
<p>　　<strong>注</strong>：<a title="leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=952</wfw:commentRss>
		</item>
		<item>
		<title>[重要]zend studio安全漏洞解决方法:关闭代码自动提示</title>
		<link>http://www.leapsoul.cn/?p=941</link>
		<comments>http://www.leapsoul.cn/?p=941#comments</comments>
		<pubDate>Wed, 14 Jul 2010 05:25:54 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[PHP开源系统]]></category>

		<category><![CDATA[PHP开发工具]]></category>

		<category><![CDATA[zend studio代码提示]]></category>

		<category><![CDATA[zend studio自动提示]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=941</guid>
		<description><![CDATA[以图文形式介绍如何关闭zend studio代码自动提示(Content Assist auto activation)功能以解决zend studio安全漏洞的方法，非常重要的zend studio教程]]></description>
			<content:encoded><![CDATA[<p>　　昨天我在网上看到一则消息：zend studio惊爆严重安全漏洞，著名安全从业人员Saiy于2010年7月10日发布了Zend Studio的安全漏洞。 通过这个漏洞，可以在操作系统中执行任意命令。在Zend Studio 6.0以上版本中，如果开发者开启了代码自动提示功能，开发者就很可能触发这个漏洞，以执行他人指定的代码。<a href="http://www.leapsoul.cn">PHP教程网</a>特提醒各位phper童鞋在打开不受信任的代码之前，请关闭zend studio的代码自动提示功能。现以zend studio教程形式告诉大家如何关闭zend studio代码提示功能。<span id="more-941"></span></p>
<p>　　我使用的是zend studio7，现介绍关闭zend studio代码提示方法</p>
<p>　　1、打开zend studio，找到Project菜单，点击Zend Tools，如图<br />
<div id="attachment_944" class="wp-caption aligncenter" style="width: 377px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-tools.gif"><img class="size-full wp-image-944 " title="zend studio关闭代码自动提示教程:点击右上角options" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-tools.gif" alt="zend studio关闭代码自动提示教程" width="367" height="94" /></a><p class="wp-caption-text">zend studio关闭代码自动提示教程:点击右上角options</p></div></p>
<div id="attachment_945" class="wp-caption aligncenter" style="width: 213px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-tools-clear.gif"><img class="size-full wp-image-945" title="zend studio关闭代码自动提示教程:点击左上角Clear图标" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-tools-clear.gif" alt="zend studio关闭代码自动提示教程:点击左上角Clear图标" width="203" height="92" /></a><p class="wp-caption-text">zend studio关闭代码自动提示教程:点击左上角Clear图标</p></div>
<div id="attachment_946" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-tools-auto-activation.gif"><img class="size-full wp-image-946  " title="zend studio关闭代码自动提示教程:去除enable auto activation勾选" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/zend-tools-auto-activation.gif" alt="zend studio关闭代码自动提示教程:去除auto activation勾选" width="480" height="336" /></a><p class="wp-caption-text">zend studio关闭代码自动提示教程:去除enable auto activation勾选</p></div>
<p>　　上图选择Editor，再点击Content Assist，将右侧enable auto activation选项勾除，最后点击apply确认，zend studio代码自动提示功能就关闭了。</p>
<p>　　更多zend studio使用方法请参考<a href="http://www.leapsoul.cn/?p=791">PHP开发工具Zend Studio7入门使用教程</a></p>
<p>　　<strong>注</strong>：<a title="leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=941</wfw:commentRss>
		</item>
		<item>
		<title>PHP调试工具Xdebug安装配置教程</title>
		<link>http://www.leapsoul.cn/?p=935</link>
		<comments>http://www.leapsoul.cn/?p=935#comments</comments>
		<pubDate>Wed, 14 Jul 2010 03:20:13 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[xdebug安装]]></category>

		<category><![CDATA[xdebug教程]]></category>

		<category><![CDATA[xdebug配置]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=935</guid>
		<description><![CDATA[以PHP教程形式介绍PHP调试工具Xdebug安装和在PHP.INI中Xdebug配置细节，涉及Xdebug下载地址以及Xdebug部分配置选项说明和xdebug not loaded as zend extension出现的原因及解决方法，不可多得的Xdebug教程。]]></description>
			<content:encoded><![CDATA[<p>　　说道PHP代码调试，对于有经验的PHPer，通过echo、print_r、var_dump函数，或<a title="PHP开发工具Zend Studio7入门使用教程" href="http://www.leapsoul.cn/?p=791">PHP开发工具zend studio</a>、editplus可解决大部分问题，但是对于PHP入门学习的童鞋来说有一定的难度，而且仅仅通过上述这些PHP调试手段，也很难准确发现PHP性能方面的问题，Xdebug是一个非常有用的PHP调试工具。</p>
<p>　　Xdebug作为PHP调试工具，提供了丰富的调试函数，也可将Xdebug安装配置为zend studio、editplus调试PHP的第三方插件，通过开启自动跟踪(auto_trace)和分析器功能，可以直观的看到PHP源代码的性能数据，以便优化PHP代码。今天和大家分享PHP调试工具Xdebug安装以及配置方面的基础知识。<span id="more-935"></span></p>
<p>　　Xdebug在PHP中的安装配置涉及php.ini配置文件的修改。</p>
<p>　　<strong>Xdebug安装教程</strong></p>
<p>　　<em>下载Xdebug</em></p>
<p>　　首先我们需要<a title="点击下载Xdebug" href="http://xdebug.org/download.php" target="_blank">下载Xdebug</a>，务必根据安装的PHP版本，选择合适的Xdebug版本，由于我是在Windows环境下安装PHP的(请参考<a href="http://www.leapsoul.cn/?p=695">Windows 7下安装配置PHP+Apache+Mysql环境教程</a>)，所以选择下载Windows版本的Xdebug2.1.0(5.3 VC6 (32 bit))，下载下来的Xdebug文件为php_xdebug-2.1.0-5.3-vc6.dll，这是由于Xdebug是作为PHP模块的形式被安装配置与使用的。</p>
<p>　　<strong>Xdebug安装提示</strong>：如果你不清楚安装的PHP版本，你可以通过phpinfo()函数参看，同时Xdebug也提供了phpinfo输出信息分析工具来帮助你分析如何安装Xdebug，只要将phpinfo输出信息复制提交即可，地址：<a href="http://xdebug.org/find-binary.php" target="_blank">Xdebug phpinfo信息分析地址</a></p>
<p>　　<em>安装Xdebug</em></p>
<p>　　将下载的php_xdebug-2.1.0-5.3-vc6.dll复制到PHP安装目录下的ext目录，此处为C:\php\ext，ext目录专门用来存放PHP扩展库DLL文件。</p>
<p>　　<em>配置php.ini</em></p>
<p>　　安装Xdebug的最后一步就是配置php.ini文件，打开C:\php目录下的php.ini配置文件，在末尾添加</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">[Xdebug]<br />
zend_extension=&quot;c:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll&quot;</div></td></tr></tbody></table></div>
<p>最后重启Apache服务器，通过phpinfo()函数，可以看到<br />
<div id="attachment_937" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/xdebug-config.gif"><img class="size-full wp-image-937 " title="PHP Xdebug配置信息" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/xdebug-config.gif" alt="Xdebug配置信息" width="480" height="118" /></a><p class="wp-caption-text">PHP Xdebug配置信息</p></div></p>
<p>　　<strong>Xdebug配置提示</strong>：PHP5.3之前版本配置Xdebug时使用zend_extension_ts，对于PHP5.3以上版本，使用zend_extension。</p>
<p>　　<strong>XDEBUG NOT LOADED AS ZEND EXTENSION信息出现的原因</strong></p>
<p>　　出现XDEBUG NOT LOADED AS ZEND EXTENSION的原因是在安装Xdebug时由于我们将Xdebug的DLL文件复制到了php\ext目录下，容易以PHP扩展库的形式加载Xdebug，在php.ini文件中添加了</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">extension=php_xdebug-2.1.0-5.3-vc6.dll</div></td></tr></tbody></table></div>
<p>这是错误的Xdebug安装方式，必须以zend方式加载。</p>
<p>　　至此PHP Xdebug的基础安装教程就结束了，下面我们需要对Xdebug作一些基础配置。</p>
<p><strong>Xdebug配置教程</strong></p>
<p>　　在安装完Xdebug后，我们还需要对Xdebug做基础配置，默认Xdebug的PHP函数自动跟踪(auto_trace)功能、分析器功能并没有开启，作为调试PHP代码的需要，有些Xdebug配置选项最好开启。</p>
<p>　　在此之前我们需要创建Xdebug自动跟踪以及分析器输出文件的存放目录，务必确保目录是可读写的，此处我在D:\PHPWeb\下创建了xdebug\trace以及xdebug\profiler目录。</p>
<p>　　最后在php.ini配置文件中完成Xdebug的配置工作，找到</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">[Xdebug]<br />
zend_extension=&quot;c:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll&quot;</div></td></tr></tbody></table></div>
<p>在此之后添加Xdebug配置信息</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">xdebug.auto_trace=1<br />
xdebug.collect_params=1<br />
xdebug.collect_return=1<br />
xdebug.trace_output_dir=&quot;D:/PHPWeb/xdebug/trace&quot;<br />
xdebug.profiler_enable=1<br />
xdebug.profiler_output_dir=&quot;D:/PHPWeb/xdebug/profiler&quot;</div></td></tr></tbody></table></div>
<p>最后保存php.ini，并重启Aapche服务器即可。</p>
<p><em>Xdebug部分配置选项说明</em></p>
<p>　　<em>xdebug.auto_trace = 1</em></p>
<p>　　是否允许Xdebug跟踪函数调用，跟踪信息以文件形式存储，默认值为0</p>
<p>　　<em>collect_params = 1</em></p>
<p>　　是否允许Xdebug跟踪函数参数，默认值为0</p>
<p>　　<em>xdebug.collect_return = 1</em></p>
<p>　　是否允许Xdebug跟踪函数返回值，默认值为0</p>
<p>　　<em>xdebug.profiler_enable = 1</em></p>
<p>　　打开xdebug的性能分析器，以文件形式存储，这项配置是不能以ini_set()函数配置的，默认值为0</p>
<p>　　<em>xdebug.profiler_output_dir</em></p>
<p>　　性能分析文件的存放位置，默认值为/tmp</p>
<p>　　<em>xdebug.profiler_output_name</em></p>
<p>　　性能分析文件的命名规则，默认值为cachegrind.out.%p</p>
<p>　　<em>xdebug.trace_output_dir</em></p>
<p>　　函数调用跟踪信息输出文件目录，默认值为/tmp</p>
<p>　　<em>xdebug.trace_output_name</em></p>
<p>　　函数调用跟踪信息输出文件命名规则，默认为trace.%c</p>
<p>　　<strong>特别说明</strong>：Xdebug的trace和profiler的输出文件名规则是可以更改的，比如将文件名命名为具体跟踪的PHP执行文件名、进程ID、随机数等，非常方便，更多的Xdebug配置选项说明，请参考官网的<a title="Xdebug配置选项说明" href="http://xdebug.org/docs/all_settings" target="_blank">Xdebug配置选项说明</a>。</p>
<p>　　至此PHP调试工具Xdebug教程之Xdebug的安装和配置就介绍完了，今后还将陆续介绍Xdebug如何在zend studio以及editplus中配置使用。</p>
<p>　　<strong>注</strong>：<a title="leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=935</wfw:commentRss>
		</item>
		<item>
		<title>phpmyadmin教程:使用phpmyadmin创建用户、数据库表的方法</title>
		<link>http://www.leapsoul.cn/?p=916</link>
		<comments>http://www.leapsoul.cn/?p=916#comments</comments>
		<pubDate>Sun, 11 Jul 2010 07:16:06 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[我的原创]]></category>

		<category><![CDATA[phpmyadmin使用教程]]></category>

		<category><![CDATA[phpmyadmin教程]]></category>

		<category><![CDATA[phpmyadmin权限设置]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=916</guid>
		<description><![CDATA[介绍使用phpmyadmin创建用户和权限设置的方法以及如何使用phpmyadmin创建数据库表并对特定数据库表进行权限设置，简单实用的phpmyadmin教程，适合php入门学习者使用。]]></description>
			<content:encoded><![CDATA[<p>　　phpmyadmin作为管理Mysql数据库的利器，越来越受到PHP网站开发建设者的欢迎，在此之前我介绍了两篇phpmyadmin入门教程：<a href="http://www.leapsoul.cn/?p=778">phpmyadmin3安装配置图解教程</a>和<a href="http://www.leapsoul.cn/?p=861">允许phpmyadmin空密码登录的配置方法</a>，今天继续phpmyadmin教程学习，介绍如何使用phpmyadmin创建添加新用户进行用户权限设置以及如何使用phpmyadmin创建数据库表的方法。<span id="more-916"></span></p>
<p>　　在使用phpmyadmin管理Mysql数据库之前，请确保Mysql服务已启动，即</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">net start mysql</div></td></tr></tbody></table></div>
<p><strong>phpmyadmin教程：创建添加新用户及权限设置的使用方法</strong></p>
<p>　　1、登入phpmyadmin管理首页，点击右侧上方<em>权限</em>菜单，会列出当前所有用户及用户权限级别，点击<em>添加新用户</em>链接即进入用户权限设置界面，可创建新用户<br />
<div id="attachment_919" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/user-quanxian.gif"><img class="size-full wp-image-919  " title="phpmyadmin创建添加新用户并进行权限设置教程" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/user-quanxian.gif" alt="创建添加新用户并进行权限配置" width="480" height="276" /></a><p class="wp-caption-text">phpmyadmin创建添加新用户并进行权限设置教程</p></div></p>
<p>　　在登录信息中主要包含用户名、主机、密码三个选项，用户名选择任意用户或使用文本域选项本质没有什么区别，推荐选择使用文本域；如果不想设置用户密码可选无密码项</p>
<p>　　主机有四种选项：任意主机(%)、本地( localhost)、使用主机表(host)、使用文本域，分别表示匹配所有主机；仅限本地主机(自动填写为localhost)；使用主机表表示以Mysql数据库中的host表中的数据替代，可不填，如果添了主机数据，则此选项无效；使用文本域表示自行填写主机信息。</p>
<p>　　<strong>特别说明</strong>：使用主机表非常有意思，如果你在mysql.host表中创建了一个host为127.0.0.1的主机，主机选择主机表，则你既可以以mysql_connect(&#8221;",&#8221;用户名&#8221;,&#8221;密码&#8221;)连接Mysql也可以以mysql_connect(&#8221;127.0.0.1&#8243;,&#8221;用户名&#8221;,&#8221;密码&#8221;)连接Mysql。</p>
<p>　　用户数据库一栏有三种选择，仅创建添加新用户、创建数据库并授予所有权限、给以用户名_ 开头的数据库 (username\_%) 授予所有权限，你可以根据Mysql数据库设计的需要自行选择，这里我选择无，即仅创建添加新用户。</p>
<p>　　创建新用户后，全局权限一栏显示USAGE表示此用户无权限，这是因为我们还没有对此用户进行权限设置，所以我们必须对创建的用户授权，点击<em>权限</em>菜单，对leapsoulcn用户点击<em>编辑权限</em>操作图标，如图<br />
<div id="attachment_921" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/user-quanxian-info.gif"><img class="size-full wp-image-921" title="phpmyadmin用户权限设置详细信息" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/user-quanxian-info.gif" alt="phpmyadmin用户权限设置详细信息" width="480" height="352" /></a><p class="wp-caption-text">phpmyadmin用户权限设置详细信息</p></div></p>
<p>　　Mysql用户权限分为四种类型数据、结构、管理、资源限制，可根据需要自行设置或点击全选执行即可。</p>
<p>　　如想删除添加的新用户，只要勾选删除用户，点击添加新用户下的删除选中的用户右侧执行按钮即可，如图<br />
<div id="attachment_922" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/del-user.gif"><img class="size-full wp-image-922" title="phpmyadmin删除用户教程" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/del-user.gif" alt="phpmyadmin删除用户教程" width="480" height="98" /></a><p class="wp-caption-text">phpmyadmin删除用户教程</p></div></p>
<p>　　如果在添加用户时选择了 创建与用户同名的数据库并授予所有权限 ，同时确实想删除此用户管理的数据库，可一并勾选删除与用户同名的数据库选项。</p>
<p><strong>phpmyadmin教程：创建与修改数据库、数据表的使用方法</strong></p>
<p>　　使用phpmyadmin创建数据库非常简单，phpmyadmin管理首页即有创建数据库的入口，如图<br />
<div id="attachment_924" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-create-db.gif"><img class="size-full wp-image-924" title="phpmyadmin创建数据库教程" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-create-db.gif" alt="phpmyadmin创建数据库教程" width="480" height="124" /></a><p class="wp-caption-text">phpmyadmin创建数据库教程</p></div></p>
<p>　　此处我建立了数据库名为leapsoulcn的数据库，同时设定字符集为GBK，点击创建按钮即进入创建数据表管理界面</p>
<div id="attachment_926" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-create-tables.gif"><img class="size-full wp-image-926" title="phpmyadmin创建数据表教程" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-create-tables.gif" alt="phpmyadmin创建数据表教程" width="480" height="176" /></a><p class="wp-caption-text">phpmyadmin创建数据表教程</p></div>
<p>　　填写数据表名及字段数，点击执行，即进入数据表字段管理界面<br />
<div id="attachment_927" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-create-tables-info.gif"><img class="size-full wp-image-927" title="phpmyadmin创建数据表字段教程" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-create-tables-info.gif" alt="phpmyadmin创建数据表字段教程" width="480" height="161" /></a><p class="wp-caption-text">phpmyadmin创建数据表字段教程</p></div></p>
<p>　　使用phpmyadmin创建最基础的数据表主要关注字段、类型、长度/值、整理(字符集)、索引(PRIMARY\UNIQUE\INDEX\FULLTEXT)、A_I(AUTO_INCREMENT)、字段注释、表注释，创建表时请注意字符集统一，否则容易导致Mysql出现乱码。</p>
<p>　　如果想要使用phpmyadmin修改数据表结构，可点击右侧数据库，再点击<em>结构</em>菜单，会列出所选数据中的所有表信息，在操作一栏中选择结构操作即可。</p>
<p>　　如何使用phpmyadmin删除数据库或数据表？只要选择左侧相应数据库，再点击右侧上方红色的<em>删除</em>菜单，即代表删除数据库(DROP DATABASE)，如果想要删除某张数据表(DROP TABLE)，请选择左侧数据库后再选择左侧数据库列出的相应数据表后再点击<em>删除</em>菜单，请勿混淆，不同的层次，删除菜单代表的功能是不同的。</p>
<p>　　如想使用phpmyadmin修改已创建的数据库，选择左侧相应数据库后，点击<em>操作</em>菜单，如图<br />
<div id="attachment_928" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-modify-db.gif"><img class="size-full wp-image-928" title="使用phpmyadmin修改数据库" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-modify-db.gif" alt="使用phpmyadmin修改数据库" width="480" height="341" /></a><p class="wp-caption-text">使用phpmyadmin修改数据库</p></div></p>
<p>　　你可使用phpmyadmin进行重命名数据库、创建数据表、修改数据库字符集等操作，简单实用。</p>
<p><strong>phpmyadmin教程：用户对特定数据库的管理权限设置方法</strong></p>
<p>　　使用phpmyadmin不但可以对全局用户权限进行设置，也可以针对某个数据库设置用户权限，但是在此之前请务必确保已对此用户进行了授权，否则对特定数据库的权限设置是无效的。</p>
<p>　　phpmyadmin权限设置入口有两种方式，一种是phpmyadmin主页权限菜单，一种是点击某个数据库，选择权限菜单，对相应的用户点击<em>编辑权限</em>操作进入权限设置界面<br />
<div id="attachment_929" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-db-quanxian.gif"><img class="size-full wp-image-929" title="使用phpmyadmin对特定用户对特定数据库的权限进行设置" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-db-quanxian.gif" alt="使用phpmyadmin对特定用户对特定数据库的权限进行设置" width="480" height="89" /></a><p class="wp-caption-text">使用phpmyadmin对特定用户对特定数据库的权限进行设置</p></div></p>
<p>　　选择特定的数据，比如leapsoulcn数据库后会自动跳转到此数据库的用户权限设置界面<br />
<div id="attachment_930" class="wp-caption aligncenter" style="width: 490px"><a href="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-db-quanxian-config.gif"><img class="size-full wp-image-930" title="使用phpmyadmin对特定数据库权限进行设置" src="http://www.leapsoul.cn/wp-content/uploads/2010/07/phpmyadmin-db-quanxian-config.gif" alt="使用phpmyadmin对特定数据库权限进行设置" width="480" height="350" /></a><p class="wp-caption-text">使用phpmyadmin对特定数据库权限进行设置</p></div></p>
<p>　　依此类推，在按表指定权限中选择相应的数据表即进入对特定表的权限设置界面，非常方便。</p>
<p>　　至此如何使用phpmyadmin创建用户并进行权限设置、如何使用phpmyadmin创建管理数据库表的phpmyadmin教程就介绍完了，今后将不断完善phpmyadmin使用教程，方便大家更好的使用phpmyadmin管理Mysql数据库。</p>
<p>　　<strong>注</strong>：<a title="leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=916</wfw:commentRss>
		</item>
		<item>
		<title>PHP环境下Fckeditor上传图片配置教程</title>
		<link>http://www.leapsoul.cn/?p=897</link>
		<comments>http://www.leapsoul.cn/?p=897#comments</comments>
		<pubDate>Wed, 07 Jul 2010 05:52:55 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[PHP开源系统]]></category>

		<category><![CDATA[建站教程]]></category>

		<category><![CDATA[我的原创]]></category>

		<category><![CDATA[fckeditor php上传]]></category>

		<category><![CDATA[fckeditor上传图片]]></category>

		<category><![CDATA[fckeditor上传路径]]></category>

		<category><![CDATA[fckeditor上传配置]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=897</guid>
		<description><![CDATA[详解PHP环境下如何配置Fckeditor2.6.6上传图片功能，涉及Fckeditor图片上传路径配置、限制上传图片文件大小方法、重命名上传图片解决文件名重名及中文乱码方法以及如何添加图片水印，非常实用的Fckeditor PHP上传教程。]]></description>
			<content:encoded><![CDATA[<p>　　上一篇PHP入门教程介绍<a href="http://www.leapsoul.cn/?p=876">Fckeditor在PHP环境中安装与配置使用方法</a>，今天介绍Fckeditor上传图片功能在PHP中的配置方法，涉及Fckeditor上传图片的上传路径配置、限制Fckeditor上传图片大小设置、Fckeditor上传图片文件名重名及乱码解决方法以及针对上传图片添加水印功能的实现方法，只要掌握了以上四点，Fckeditor在大部分PHP类型网站中的应用都能解决。<span id="more-897"></span></p>
<p><strong>开启Fckeditor上传图片功能</strong></p>
<p>　　考虑到目录安全性问题，默认Fckeditor2.6.6上传功能并未开启，所以第一步我们必须开启Fckeditor上传功能，这里需要注意，由于PHP版本Fckeditor上传功能需要用到chomod函数对新建目录进行权限设置，所以请务必确认在启用Fckeditor上传功能时PHP环境的用户具有创建和更改上传目录的权限。</p>
<p>　　如果没有开启Fckeditor上传功能，在点击<em>插入/编辑图像</em>按钮，选择<em>上传</em>，在选择完要上传的文件后点击<em>发送到服务器上</em>按钮时会报错误信息如下</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">This file uploader is disabled.<br />
<br />
Please check the &quot;editor/filemanager/connectors/php/config.php&quot; file</div></td></tr></tbody></table></div>
<p>根据错误信息，打开editor/filemanager/connectors/php目录下config.php，找到</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$Config</span><span class="br0">&#91;</span><span class="st_h">'Enabled'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="kw2">false</span> <span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>更改为</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$Config</span><span class="br0">&#91;</span><span class="st_h">'Enabled'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="kw2">true</span> <span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>并在相应目录下建立userfiles上传目录后，Fckeditor上传图片功能开启。</p>
<p>　　<strong>特别提醒</strong>：Fckeditor似乎有个BUG漏洞，即JS兼容性还不是太完美，之前我在Google Chrome游览器下设置完后，Fckeditor PHP上传一直实现不了，换了IE后一切正常。</p>
<p><strong>Fckeditor上传图片时上传路径配置教程</strong></p>
<p>　　作为独立网站开发者，除了考虑技术还需要兼顾其他方便，比如SEO优化，而目录结构(URL)优化是SEO的一部分，这就需要在设置Fckeditor上传图片功能时考虑图片上传路径问题。</p>
<p>　　默认Fckeditor图片上传路径结构有两种形式：userfiles/文件名和userfiles/文件类型/文件名，针对两种Fckeditor上传方式：快速上传（图像属性中的上传）和服务器游览上传（图像属性中的链接），比如上传图片，QuickUpload模式上传路径为userfiles/文件名，服务器游览上传模式上传路径为userfiles/images/文件名。</p>
<p><em>Fckeditor图片上传路径配置如下</em></p>
<p>　　打开editor/filemanager/connectors/php目录下config.php文件，找到</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$Config</span><span class="br0">&#91;</span><span class="st_h">'UserFilesPath'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'/userfiles/'</span> <span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>更改为</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$Config</span><span class="br0">&#91;</span><span class="st_h">'UserFilesPath'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'/项目目录/userfiles/'</span> <span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>注意：此处userfiles文件夹是针对http://localhost/的根目录而言的。</p>
<p>　　以上是默认Fckeditor上传路径的配置，根据URL规划你可以自定义Fckeditor的上传目录，只要修改config.php文件中的$Config['FileTypesPath']、$Config['FileTypesAbsolutePath']、$Config['QuickUploadPath']、$Config['QuickUploadAbsolutePath']四个上传目录路径的值即可。这种方法一定程度上也能避免Fckeditor上传图片文件名重名问题。</p>
<p><strong>限制Fckeditor上传图片大小设置</strong></p>
<p>　　Fckeditor2.6.6默认并没有限制上传图片文件的大小，可以通过两种方法改进，一种可以通过修改<a href="http://www.leapsoul.cn/?p=488">PHP.INI配置文件上传</a>大小来限制，另一种方法只能手动修改Fckeditor源码，方法如下</p>
<p>　　1、打开editor/filemanager/connectors/php目录下config.php，创建Config变量设置上传图片大小，这里以KB为单位</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$Config</span><span class="br0">&#91;</span><span class="st_h">'MaxImageSize'</span><span class="br0">&#93;</span><span class="sy0">=</span> <span class="st_h">'1024'</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>　　2、打开editor/filemanager/connectors/php目录下commands.php，找到</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span> <span class="re0">$Config</span><span class="br0">&#91;</span><span class="st_h">'SecureImageUploads'</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span> <span class="br0">&#40;</span> <span class="re0">$isImageValid</span> <span class="sy0">=</span> IsImageValid<span class="br0">&#40;</span> <span class="re0">$oFile</span><span class="br0">&#91;</span><span class="st_h">'tmp_name'</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="re0">$sExtension</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="sy0">===</span> <span class="kw2">false</span> <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$sErrorNumber</span> <span class="sy0">=</span> <span class="st_h">'202'</span> <span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="co1">//上传图片大小限制</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>在上传图片大小限制处，添加</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span> <span class="re0">$Config</span><span class="br0">&#91;</span><span class="st_h">'MaxImageSize'</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$iFileSize</span> <span class="sy0">=</span> <a href="http://www.php.net/round"><span class="kw3">round</span></a><span class="br0">&#40;</span> <span class="re0">$oFile</span><span class="br0">&#91;</span><span class="st_h">'size'</span><span class="br0">&#93;</span> <span class="sy0">/</span> <span class="nu0">1024</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$iFileSize</span> <span class="sy0">&amp;</span>gt<span class="sy0">;</span> <span class="re0">$Config</span><span class="br0">&#91;</span><span class="st_h">'MaxImageSize'</span><span class="br0">&#93;</span> <span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sErrorNumber</span> <span class="sy0">=</span> <span class="st_h">'204'</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>说明</strong>：由于PHP计算上传图片大小以字节为单位，所以代码首先将上传的图片大小折算为KB，再来对比是否超出了规定的图片大小，如超出，则报错。</p>
<p>　　注意最后将</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">if</span> <span class="br0">&#40;</span> <span class="sy0">!</span><span class="re0">$sErrorNumber</span> <span class="sy0">&amp;&amp;</span> IsAllowedExt<span class="br0">&#40;</span> <span class="re0">$sExtension</span><span class="sy0">,</span> <span class="re0">$resourceType</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="co1">//Fckeditor上传图片功能</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">else</span><br />
<span class="re0">$sErrorNumber</span> <span class="sy0">=</span> <span class="st_h">'202'</span> <span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>代码块结尾处的else语句去除，否则实现不了限制Fckeditor上传图片文件大小的功能。</p>
<p>　　3、打开editor/dialog/fck_image/fck_image.js，添加错误代码(errorNumber)信息，找到OnUploadCompleted函数，添加</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">case 204 :<br />
alert( &quot;Security error. File size error.&quot; ) ;<br />
return ;</div></td></tr></tbody></table></div>
<p>　　至此限制Fckeditor上传图片文件大小配置就完成了，其他类型的上传文件大小限制也是这种思路。</p>
<p><strong>Fckeditor上传图片文件名重名及中文乱码解决方法</strong></p>
<p>　　经测试Fckeditor2.6.6并没有解决上传文件中文名变为乱码的问题，这是由于Fckeditor实现上传功能时并没有将文件重命名，容易导致上传图片文件重名及乱码问题。</p>
<p>　　上传图片文件重名和乱码解决方法如下</p>
<p>　　打开editor/filemanager/connectors/php目录下commands.php，找到FileUpload函数，在</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$sExtension</span> <span class="sy0">=</span> <a href="http://www.php.net/substr"><span class="kw3">substr</span></a><span class="br0">&#40;</span> <span class="re0">$sFileName</span><span class="sy0">,</span> <span class="br0">&#40;</span> <a href="http://www.php.net/strrpos"><span class="kw3">strrpos</span></a><span class="br0">&#40;</span><span class="re0">$sFileName</span><span class="sy0">,</span> <span class="st_h">'.'</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">1</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="sy0">;</span><br />
<span class="re0">$sExtension</span> <span class="sy0">=</span> <a href="http://www.php.net/strtolower"><span class="kw3">strtolower</span></a><span class="br0">&#40;</span> <span class="re0">$sExtension</span> <span class="br0">&#41;</span> <span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>后添加</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$sFileName</span> <span class="sy0">=</span> <a href="http://www.php.net/rand"><span class="kw3">rand</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">100</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st0">&quot;.&quot;</span><span class="sy0">.</span><span class="re0">$sExtension</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>此处rand函数可根据需要自行改变重命名规则。</p>
<p>　　另一种上传图片文件名乱码解决方法为使用iconv函数对文件名进行编码转换，但仍然存在重名问题，所以针对Fckeditor上传图片文件名最好还是重命名。</p>
<p><strong>Fckeditor上传图片添加水印功能</strong></p>
<p>　　对于网站拥有者来说保护图片版权添加水印必不可少，我们可以利用PHP添加水印函数结合Fckeditor文件上传函数FileUpload实现图片添加水印功能，水印函数请参考<a href="http://www.leapsoul.cn/?p=171">PHP图片水印函数:支持以图片和文字方式添加水印</a>一文。</p>
<p>　　至此Fckeditor在PHP环境下的上传图片配置入门教程就介绍完了。</p>
<p>　　<strong>注</strong>：<a title="leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=897</wfw:commentRss>
		</item>
		<item>
		<title>PHP环境Fckeditor安装配置与使用方法教程</title>
		<link>http://www.leapsoul.cn/?p=876</link>
		<comments>http://www.leapsoul.cn/?p=876#comments</comments>
		<pubDate>Sun, 27 Jun 2010 13:23:11 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[建站教程]]></category>

		<category><![CDATA[fckeditor php配置]]></category>

		<category><![CDATA[fckeditor使用方法]]></category>

		<category><![CDATA[fckeditor安装]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=876</guid>
		<description><![CDATA[以PHP教程形式介绍Fckeditor2.6.6在PHP环境中的安装方法和Fckeditor使用方法说明，同时详解Fckeditor PHP配置的两种方法，即定义Config数组及修改fckeditor.js文件实现工具栏配置、Skin更换等属性配置。]]></description>
			<content:encoded><![CDATA[<p>　　在使用PHP开发留言板、CMS、博客时都涉及文本信息的处理，如何将信息优美地展现在读者面前是PHP网站开发建设者所追求的，而在线编辑器实现了可视化的功能，最早PHP网站开发者都是使用UBB来实现文本信息的展现功能，之后出现了类似于WORD的在线编辑器，今天和大家介绍的是老牌在线编辑器Fckeditor在PHP环境中安装配置与使用方法说明。</p>
<p>　　Fckeditor支持多种开发语言，如PHP、.NET、JAVA等，本文使用的是Fckeditor2.6.6版本，主要介绍Fckeditor2.6.6在PHP环境中如何安装配置以及使用说明。<span id="more-876"></span></p>
<p>　　<strong>准备工作</strong></p>
<p>　　首先我们需要下载Fckeditor安装源码包，请点击<a title="下载Fckeditor" href="http://ckeditor.com/download" target="_blank">下载Fckeditor</a>，推荐下载Fckeditor2.6.6，根据系统环境你可以下载zip包或者tar.gz包。</p>
<p>　　另外如果没有进行<a title="安装配置PHP环境" href="http://www.leapsoul.cn/?tag=php环境配置">PHP环境配置</a>，先配置PHP环境。</p>
<p>　　<strong>Fckeditor安装说明</strong></p>
<p>　　Fckeditor安装非常方便，只要解压下载的Fckeditor2.6.6.zip包，将解压的Fckeditor2.6.6文件夹下fckeditor文件夹复制到相应项目文件夹下即可。</p>
<p>　　<strong>Fckeditor使用方法说明</strong></p>
<p>　　Fckeditor使用较为简单，由于Fckeditor基本上都是使用在Form表单中，以方便用户使用Fckeditor输入相关信息后提交到Mysql数据库，所以</p>
<p>　　<em>第一步</em>：先建立FORM表单以方便使用Fckeditor，FORM表单如下</p>
<div class="codecolorer-container html4strict mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="html4strict codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc2">&lt;<a href="http://december.com/html/4/element/head.html"><span class="kw2">head</span></a>&gt;</span><br />
<span class="sc2">&lt;<a href="http://december.com/html/4/element/title.html"><span class="kw2">title</span></a>&gt;</span>PHP教程-Fckeditor2.6.6在PHP环境中安装配置与使用方法说明<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/title.html"><span class="kw2">title</span></a>&gt;</span><br />
<span class="sc2">&lt;<a href="http://december.com/html/4/element/meta.html"><span class="kw2">meta</span></a> <span class="kw3">http-equiv</span><span class="sy0">=</span><span class="st0">&quot;Content-Type&quot;</span> <span class="kw3">content</span><span class="sy0">=</span><span class="st0">&quot;text/html; charset=GBK&quot;</span>&gt;</span><br />
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/head.html"><span class="kw2">head</span></a>&gt;</span><br />
<span class="sc2">&lt;<a href="http://december.com/html/4/element/body.html"><span class="kw2">body</span></a>&gt;</span><br />
<span class="sc2">&lt;<a href="http://december.com/html/4/element/form.html"><span class="kw2">form</span></a> <span class="kw3">action</span><span class="sy0">=</span><span class="st0">&quot;leapsoulcn.php&quot;</span> <span class="kw3">method</span><span class="sy0">=</span><span class="st0">&quot;post&quot;</span> <span class="kw3">target</span><span class="sy0">=</span><span class="st0">&quot;_blank&quot;</span>&gt;</span><br />
/**<br />
使用Fckeditor的地方<br />
**/<br />
<span class="sc2">&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;submit&quot;</span> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">&quot;Submit&quot;</span>&gt;</span><br />
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/form.html"><span class="kw2">form</span></a>&gt;</span><br />
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/body.html"><span class="kw2">body</span></a>&gt;</span><br />
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/html.html"><span class="kw2">html</span></a>&gt;</span></div></td></tr></tbody></table></div>
<p>　　<em>第二步</em>：建立好表单，由于Fckeditor其实也是第三方类库，为了使用Fckeditor，我们需要引入接口模块，fckeditor目录下有多种语言的接口文件，由于使用的是PHP，所以只要引入php类型的接口文件即可，即在FORM表单中使用Fckeditor的地方输入</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?</span><br />
<span class="kw1">include_once</span><span class="br0">&#40;</span><span class="st0">&quot;fckeditor/fckeditor.php&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
<p>　　<strong>注意点</strong>：include时注意目录结构，如果不引入此文件或引入错误会报找不到fckeditor类的错误信息。此处FORM表单文件与fckeditor文件夹属于同级目录。</p>
<p>　　<em>第三步</em>：在FORM表单使用Fckeditor的地方输入</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?</span><br />
<span class="re0">$FCKeditor</span> <span class="sy0">=</span> <span class="kw2">new</span> FCKeditor<span class="br0">&#40;</span><span class="st_h">'FCKeditor1'</span><span class="br0">&#41;</span> <span class="sy0">;</span><br />
<br />
<span class="re0">$FCKeditor</span><span class="sy0">-&gt;</span><span class="me1">BasePath</span> <span class="sy0">=</span> <span class="st_h">'fckeditor/'</span><span class="sy0">;</span><br />
<br />
<span class="re0">$FCKeditor</span><span class="sy0">-&gt;</span><span class="me1">Value</span> <span class="sy0">=</span> <span class="st_h">'&lt;p&gt;欢迎访问&lt;a href=&quot;http://www.leapsoul.cn/&quot;&gt;PHP教程网&lt;/a&gt;，本文主要介绍在PHP环境下Fckeditor安装配置与使用方法.&lt;/p&gt;'</span><span class="sy0">;</span><br />
<br />
<span class="re0">$FCKeditor</span><span class="sy0">-&gt;</span><span class="me1">Create</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
<p>　　<strong>注意点</strong>：</p>
<p>　　上述代码必须接着include_once语句，保证在一个PHP语句块中，否则使用Fckeditor仍然会报错。</p>
<p>　　定义Fckeditor类的BasePath值时，务必注意路径，根据具体情况使用相对路径或绝对路径，否则仍然不能使用Fckeditor。</p>
<p>　　至此在PHP中Fckeditor的入门使用方法和实例使用说明就介绍完了，但是在PHP网站开发中，Fckeditor的基础使用往往并不能满足需要，比如在前台，考虑安全性等因素，并不需要将Fckeditor的所有功能开放给用户使用，这时我们就要对Fckeditor进行配置。</p>
<p>　　<strong>Fckeditor配置说明</strong></p>
<p>　　Fckeditor php配置主要通过两种方法，一种通过Fckeditor类的公有变量及其config数组进行Fckeditor配置，一种通过修改fckeditor目录下的fckeditor.js文件实现Fckeditor配置功能。</p>
<p>　　常用的Fckeditor配置主要涉及Fckeditor输入框的宽度和高度配置、工具栏配置、皮肤配置。</p>
<p>　　<em>如何配置Fckeditor输入框的宽度和高度</em></p>
<p>　　可以在使用Fckeditor类时配置，即</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?</span><br />
<span class="re0">$FCKeditor</span><span class="sy0">-&gt;</span><span class="me1">Width</span> <span class="sy0">=</span> <span class="st_h">'400'</span><span class="sy0">;</span><br />
<br />
<span class="re0">$FCKeditor</span><span class="sy0">-&gt;</span><span class="me1">Height</span> <span class="sy0">=</span> <span class="st_h">'300'</span><span class="sy0">;</span><br />
<span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
<p>　　默认Fckeditor配置的宽度和高度为100%和200,你既可以用百分比也可以用像素(px)来进行配置。</p>
<p>　　<em>如何配置Fckeditor工具栏</em></p>
<p>　　默认Fckeditor提供两种模式的工具栏，即Default和Basic，Default提供了所有的Fckeditor工具栏功能，Basic则提供了最基础的Fckeditor工具栏功能，简而言之Default主要是为后台管理人员提供的，而Basic主要为前台用户提供，只要在使用Fckeditor类时配置</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?</span><br />
<span class="re0">$FCKeditor</span><span class="sy0">-&gt;</span><span class="me1">ToolbarSet</span> <span class="sy0">=</span> <span class="st_h">'Basic'</span><span class="sy0">;</span><br />
<span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
<p>即可，注意大小写，否则会报错。</p>
<p>　　如果你对Fckeditor提供的这两种工具栏并不满足，你可以根据需求定义自己的工具栏，可通过第二种方式，即修改fckeditor.js文件来实现，打开fckeditor.js，找到FCKConfig.ToolbarSets，你可以修改和添加Default和Basic模式中定义的工具栏功能，甚至你可以创建一个新的工具栏，比如Leapsoulcn工具栏，在fckeditor.js文件中添加</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">FCKConfig.ToolbarSets[&quot;Leapsoulcn&quot;] = [<br />
<br />
&lt;span&gt; &lt;/span&gt;['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink']<br />
<br />
] ;</div></td></tr></tbody></table></div>
<p>然后在使用Fckeditor类时，定义</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?</span><br />
<span class="re0">$FCKeditor</span><span class="sy0">-&gt;</span><span class="me1">ToolbarSet</span> <span class="sy0">=</span> <span class="st_h">'Leapsoulcn'</span><span class="sy0">;</span><br />
<span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
<p>即可使用Leapsoulcn模式的工具栏，注意工具栏分隔符|是通过-实现的，工具栏换行则通过/实现。</p>
<p>　　<em>如何配置Fckeditor皮肤</em></p>
<p>　　Fckeditor2.6.6默认提供三种皮肤，即default、office2003、silver，配置Fckeditor皮肤也有两种方式，一种通过config数组实现，一种通过修改fckeditor.js文件实现。</p>
<p>　　<strong>config数组实现方式</strong></p>
<p>　　比如想使用office2003皮肤，只要在使用Fckeditor类时，配置config数组，如下</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?</span><br />
<span class="re0">$FCKeditor</span><span class="sy0">-&gt;</span><span class="me1">Config</span><span class="br0">&#91;</span><span class="st_h">'SkinPath'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'/test/phpfck/fckeditor/editor/skins/office2003/'</span><span class="sy0">;</span><br />
<span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
<p>　　<strong>注意</strong>：SkinPath一定要使用绝对路径。</p>
<p>　　<strong>修改fckeditor.js文件实现配置Fckeditor皮肤的功能</strong></p>
<p>　　打开fckeditor.js，找到FCKConfig.SkinPath，将</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ;</div></td></tr></tbody></table></div>
<p>修改为</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/office2003/' ;</div></td></tr></tbody></table></div>
<p>　　至此基本的Fckeditor配置就介绍完了，如果在修改Fckeditor工具栏或皮肤配置后没有改变，请关闭游览器再重新访问即可。更多的Fckeditor Config配置选项今后会再介绍。</p>
<p>　　<strong>其他注意事项</strong></p>
<p>　　在使用Fckeditor时，一定要注意页面编码问题，页面编码和数据库编码必须统一，否则会出现Fckeditor输入框中内容为乱码的问题。</p>
<p>　　至此，Fckeditor2.6.6在PHP环境中的安装配置与使用方法教程就全部介绍完了。</p>
<p>　　<strong>注</strong>：<a title="leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=876</wfw:commentRss>
		</item>
		<item>
		<title>Windows下Mysql root忘记密码的处理方法</title>
		<link>http://www.leapsoul.cn/?p=871</link>
		<comments>http://www.leapsoul.cn/?p=871#comments</comments>
		<pubDate>Tue, 15 Jun 2010 08:36:15 +0000</pubDate>
		<dc:creator>david</dc:creator>
		
		<category><![CDATA[Mysql]]></category>

		<category><![CDATA[Mysql root忘记密码]]></category>

		<guid isPermaLink="false">http://www.leapsoul.cn/?p=871</guid>
		<description><![CDATA[以PHP教程形式介绍Mysql root忘记密码后使用mysqld命令和--skip-grant-tables参数实现更改root密码解决忘记root密码的方法。]]></description>
			<content:encoded><![CDATA[<p>　　Mysql数据库修改root密码有多种方法，在Mysql修改设置root密码的命令及方法一文中我进行了详细介绍，但是当你修改Mysql root密码命令操作失误或干脆忘记了root密码时，如何找回Mysql数据库root密码呢？今天就和大家分享忘记Mysql root用户密码后更改重置密码的处理方法。</p>
<p>　　Mysql root忘记密码的处理原则主要分两步：1、跳过权限限制，恢复root初始密码（Mysql root默认密码为空）以便进入Mysql命令行模式；2、修改重置root密码。<span id="more-871"></span></p>
<p>　　我的Mysql数据库5.1的安装环境是Windows7，Mysql root忘记密码的处理主要会应用到mysqld命令工具，此工具Mysql自带，存放在Mysql安装目录的bin子目录下。</p>
<p>　　<strong>注意事项</strong>：在使用mysqld命令处理Mysql root忘记密码问题时，必需确保Mysql服务停止，否则不会成功，如果默认已启动Mysql服务，你可以在DOS模式下输入</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">net stop mysql</div></td></tr></tbody></table></div>
<p>停止Mysql服务。</p>
<p>　　<strong>Mysql忘记root密码处理步骤一</strong></p>
<p>　　在停止了Mysql服务后，即可使用mysqld命令，在DOS模式下进入Mysql bin子目录，输入</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">C:\Program Files\MySQL\MySQL Server 5.1\bin&gt;mysqld --skip-grant-tables;</div></td></tr></tbody></table></div>
<p>伴随这条命令会出现如下错误信息</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">100602 22:24:28 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.</div></td></tr></tbody></table></div>
<p>此提示信息无关紧要，稍等片刻即告成功。</p>
<p>　　<strong>知识点</strong>：mysqld的&#8211;skip-grant-tables参数表示在启动mysql时不启动grant-tables（授权表），主要是在忘记Mysql root管理员密码时使用。</p>
<p>　　<strong>Mysql忘记root密码处理步骤二</strong></p>
<p>　　在使用完mysqld命令后，我们需要进入Mysql数据库命令行模式进行root密码更改重置操作，这里需要注意，必须另启一个CMD窗口，输入</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">C:\Program Files\MySQL\MySQL Server 5.1\bin&gt;mysql -uroot</div></td></tr></tbody></table></div>
<p>即进入Mysql数据库命令行模式</p>
<p>　　<strong>Mysql忘记root密码处理步骤三</strong></p>
<p>　　使用Update等Mysql修改密码命令更改root密码，具体修改root密码命令可参考<a href="http://www.leapsoul.cn/?p=849">Mysql修改设置root密码的命令及方法</a>一文</p>
<p>　　<strong>Mysql忘记root密码处理步骤四</strong></p>
<p>　　ctrl+alt+delete，打开任务管理器，删除mysql，mysqld进程，然后在DOS模式下输入</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;width:550px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">net start mysql</div></td></tr></tbody></table></div>
<p>启动mysql服务，之后就可以使用已修改的Mysql root密码进入Mysql管理模式了。</p>
<p>　　至此Mysql root忘记密码后重新设置密码的操作就完成了，个人觉得Mysql root密码忘记后还是比较繁琐，在进行PHP网站开发时最好还是要做好安全准备，以防Mysql root忘记密码问题的出现。</p>
<p>　　<strong>注</strong>：<a title="leapsoul - 分享PHP网站开发与建设的乐趣,以PHP实例教程方式教你建站" href="http://www.leapsoul.cn/">PHP网站开发教程-leapsoul.cn</a>版权所有，转载时请以链接形式注明原始出处及本声明，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leapsoul.cn/?feed=rss2&amp;p=871</wfw:commentRss>
		</item>
	</channel>
</rss>
