<?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>Hiro技术站 &#187; 后台编程</title>
	<atom:link href="http://www.ihiro.org/tag/programming-background-tag/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ihiro.org</link>
	<description></description>
	<lastBuildDate>Fri, 06 Jan 2012 07:58:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Python:Beginning Python[&#039;paiθən]</title>
		<link>http://www.ihiro.org/beginning-python</link>
		<comments>http://www.ihiro.org/beginning-python#comments</comments>
		<pubDate>Tue, 07 Dec 2010 05:13:45 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[后台编程]]></category>
		<category><![CDATA[杂记]]></category>
		<category><![CDATA[读书]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=1576</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/12/beginning-python.jpg" alt="" title="beginning-python" width="100" height="100" class="alignleft size-full wp-image-1578" />
<p>最近一直在看《Beginning Python》这边书，之所以选择英文版，一是最近在公司看的都是英文文档和电子书，阅读有所提高；二是看豆瓣对这本书的中文版的评论不是很好，因为是多人合作翻译的，所以说这本书翻译的不是很好。所以我的打算是看一本英文的基础书籍，然后再选择一本中文的中高级书籍。</p>
<p>最近比较闲，临近圣诞、新年，公司客户方都忙着过节了吧。乘着这段时间多看看专业书籍，提升一下自己。虽然会一些PHP，但我的主要目标还是放在前端，所会的那些PHP够我折腾Wordpress就可以了，根本就没打算用到工作中去。之所以选择学习了Python，主要是发现好多做前端的都会去选择这本服务器脚本语言。而在一些招聘信息上也会去要求前端会Python语言。</p>]]></description>
			<content:encoded><![CDATA[<p>最近一直在看《Beginning Python》这边书，之所以选择英文版，一是最近在公司看的都是英文文档和电子书，阅读有所提高；二是看豆瓣对这本书的中文版的评论不是很好，因为是多人合作翻译的，所以说这本书翻译的不是很好。所以我的打算是看一本英文的基础书籍，然后再选择一本中文的中高级书籍。</p>
<p>最近比较闲，临近圣诞、新年，公司客户方都忙着过节了吧。乘着这段时间多看看专业书籍，提升一下自己。虽然会一些PHP，但我的主要目标还是放在前端，所会的那些PHP够我折腾Wordpress就可以了，根本就没打算用到工作中去。之所以选择学习了Python，主要是发现好多做前端的都会去选择这本服务器脚本语言。而在一些招聘信息上也会去要求前端会Python语言。</p>
<p>好笑的是，因这个单词的发音是听到别人的发音来认识的。结果后来查了词典才发现原来一直读错了，以至于到现在老是无形中就以错误的读法来读它，悲剧！一定要改掉这个读法，所以在标题上加上音标，以此警戒!</p>
<p>最近心情有点小浮躁&#8230;</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2010年11月3日 -- <a href="http://www.ihiro.org/html5-pro-ebook-recommendations" title="HTML5:《Pro HTML5 Programming》英文电子书推荐">HTML5:《Pro HTML5 Programming》英文电子书推荐</a> (21)</li><li>2010年07月4日 -- <a href="http://www.ihiro.org/perforomance-best-pritices-for-web-developers" title="读书:《高性能网站建设进阶指南:Web开发者性能优化最佳实践 》">读书:《高性能网站建设进阶指南:Web开发者性能优化最佳实践 》</a> (10)</li><li>2009年12月11日 -- <a href="http://www.ihiro.org/pathinfo-to-obtain-filepath-and-filename" title="PHP:pathinfo()获得文件的路径、名称等信息">PHP:pathinfo()获得文件的路径、名称等信息</a> (20)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/beginning-python/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>PHP:pathinfo()获得文件的路径、名称等信息</title>
		<link>http://www.ihiro.org/pathinfo-to-obtain-filepath-and-filename</link>
		<comments>http://www.ihiro.org/pathinfo-to-obtain-filepath-and-filename#comments</comments>
		<pubDate>Fri, 11 Dec 2009 07:15:58 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[后台编程]]></category>
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=926</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/12/path-logo.png" alt="path-logo" title="path-logo" width="100" height="100" class="alignleft size-full wp-image-929" />
<p>最近试图着去阅读一些PHP编程的资料，希望通过学习可以掌握好这门开源的后台编程语言。函数是编程语言的主要组成，所以多熟悉PHP语言内部函数的应用和意义，对我以后的PHP编程意义重大。</p>
<p>近两个月来我的js编程有了很大的提高，在借助与jQuery库的帮助下，着实写出了一些很多行实用的代码，运用到了项目中。所以我有了一个想法，我想我的下一个WP主题要使用大量的js来是想效果，运用一些Ajax的特性，使得我的博客更加地人性化。但因PHP编程不熟的原因所以只能推迟。</p>
<p>在PHP中，若想通过函数获得一个文件的路径、名称，或者是扩展名等，是非常容易的一件事。可以使用dirname()、basename()、pathinfo()等多种途径获得相应的信息。</p>
<p style="color:#f00;">该文内容为个人学习之用，不关心的朋友可以不做理会！</p>]]></description>
			<content:encoded><![CDATA[<p>最近试图着去阅读一些PHP编程的资料，希望通过学习可以掌握好这门开源的后台编程语言。函数是编程语言的主要组成，所以多熟悉PHP语言内部函数的应用和意义，对我以后的PHP编程意义重大。</p>
<p>近两个月来我的js编程有了很大的提高，在借助与jQuery库的帮助下，着实写出了一些很多行实用的代码，运用到了项目中。所以我有了一个想法，我想我的下一个WP主题要使用大量的js来是想效果，运用一些Ajax的特性，使得我的博客更加地人性化。但因PHP编程不熟的原因所以只能推迟。</p>
<p>废话不说了，进入主题。</p>
<p>在PHP中，若想通过函数获得一个文件的路径、名称，或者是扩展名等，是非常容易的一件事。可以使用dirname()、basename()、pathinfo()等多种途径获得相应的信息。假设现在有一个图片文件，它的服务器端路径为：</p>

<div class="wp_codebox"><table><tr id="p9261"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p926code1"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/www/mywebsite/images/myphoto.jpg&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

</p>
<h3>1.pathinfo()函数</h3>
<p>pathinfo()函数返回的是一个包含了文件信息的数组，数组中有四个元素，分别是dirname、basename、extension、filename。打印数组的代码：</p>

<div class="wp_codebox"><table><tr id="p9262"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p926code2"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$fileArr</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/pathinfo"><span style="color: #990000;">pathinfo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileArr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：Array ( [dirname] =&gt; /www/mywebsite/images [basename] =&gt; myphoto.jpg [extension] =&gt; jpg [filename] =&gt; myphoto )</span></pre></td></tr></table></div>

<p>这样我们只需根据数组的键名就可以获得对应的键值：</p>

<div class="wp_codebox"><table><tr id="p9263"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p926code3"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$fileArr</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filename'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：myphoto  </span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$fileArr</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extension'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：jpg</span>
<span style="color: #666666; font-style: italic;">//...</span></pre></td></tr></table></div>

</p>
<h3>2.dirname()函数</h3>
<p>dirname()函数给出一个包含有指向一个文件的全路径的字符串，它返回的值去掉文件名后的目录名，可以认为是对pathinfo()函数的扩展：</p>

<div class="wp_codebox"><table><tr id="p9264"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p926code4"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <a href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：/www/mywebsite/images</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//或者</span>
<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/www/mywebsite/images/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/www/mywebsite/images&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出的结果都为：/www/mywebsite</span></pre></td></tr></table></div>

<p>所以可以理解为返回的值为路径的上一层目录地址名。
</p>
<h3>3.basename()函数</h3>
<p>basename()函数给出一个包含有指向一个文件的全路径的字符串，他返回的值为基本的文件名，同样可以认为是对pathinfo()函数的扩展：</p>

<div class="wp_codebox"><table><tr id="p9265"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p926code5"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <a href="http://www.php.net/basename"><span style="color: #990000;">basename</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：myphoto.jpg</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//或者</span>
<a href="http://www.php.net/basename"><span style="color: #990000;">basename</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/www/mywebsite/images/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：images</span></pre></td></tr></table></div>

<p>所以可以理解为返回的值为路径的当前目录的名称。
</p>
<p style="color:#f00;">该文内容为个人学习之用，不关心的朋友可以不做理会！</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2009年08月20日 -- <a href="http://www.ihiro.org/array-sort-function" title="PHP:数组排序函数大总结">PHP:数组排序函数大总结</a> (6)</li><li>2011年04月20日 -- <a href="http://www.ihiro.org/css3-transition" title="CSS3:Transition属性详解">CSS3:Transition属性详解</a> (82)</li><li>2011年04月1日 -- <a href="http://www.ihiro.org/html5-reading-note-chp4-canvas" title="HTML5:《HTML5. Up and Running》读书笔记.Chp4.Canvas">HTML5:《HTML5. Up and Running》读书笔记.Chp4.Canvas</a> (22)</li><li>2011年03月21日 -- <a href="http://www.ihiro.org/html5-reading-note-chp3-elements" title="HTML5:《HTML5. Up and Running》读书笔记.Chp3.Elements">HTML5:《HTML5. Up and Running》读书笔记.Chp3.Elements</a> (24)</li><li>2011年03月15日 -- <a href="http://www.ihiro.org/html5-reading-note-chp2-features" title="HTML5:《HTML5. Up and Running》读书笔记.Chp2.Features">HTML5:《HTML5. Up and Running》读书笔记.Chp2.Features</a> (23)</li><li>2010年12月7日 -- <a href="http://www.ihiro.org/beginning-python" title="Python:Beginning Python['paiθən]">Python:Beginning Python['paiθən]</a> (27)</li><li>2010年11月22日 -- <a href="http://www.ihiro.org/text-range" title="Range:文本框选区学习笔记">Range:文本框选区学习笔记</a> (16)</li><li>2010年08月12日 -- <a href="http://www.ihiro.org/sizzle-custom-selector" title="Sizzle:开源JS选择器，如何自定义选择器">Sizzle:开源JS选择器，如何自定义选择器</a> (31)</li><li>2009年11月25日 -- <a href="http://www.ihiro.org/wordpress-the-article-automatically-appear-as-two" title="Wordpress:将文章自动显示为两列">Wordpress:将文章自动显示为两列</a> (13)</li><li>2009年09月10日 -- <a href="http://www.ihiro.org/javascript-oop" title="Javascript:面向对象之静态、公有、私有、特权对象">Javascript:面向对象之静态、公有、私有、特权对象</a> (10)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/pathinfo-to-obtain-filepath-and-filename/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
