<?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>The Danesh Project &#187; php</title>
	<atom:link href="http://thedaneshproject.com/categories/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://thedaneshproject.com</link>
	<description>Knowledge bling's the finer things in life.</description>
	<lastBuildDate>Fri, 03 Feb 2012 09:25:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>What does dirname(__FILE__) and basename(dirname(__FILE__)) do?</title>
		<link>http://thedaneshproject.com/posts/what-does-dirname__file__-and-basenamedirname__file__-do/</link>
		<comments>http://thedaneshproject.com/posts/what-does-dirname__file__-and-basenamedirname__file__-do/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 09:44:06 +0000</pubDate>
		<dc:creator>Danesh</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[php function]]></category>
		<category><![CDATA[php script]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://thedaneshproject.com/?p=1240</guid>
		<description><![CDATA[Was helping a friend fix his php script today. He was not too sure about what &#8220;dirname(__FILE__)&#8221; did. dirname() is a PHP function which returns the directory name of a file. For example if file abc.txt was in &#8220;/tmp/abc.txt&#8221; then the dirname() function would return &#8220;/tmp&#8221; . Example Usage; &#60;?php $file = &#8220;/tmp/abc.txt&#8221;; $path = [...]]]></description>
			<content:encoded><![CDATA[<p>Was helping a friend fix his php script today. He was not too sure about what &#8220;dirname(__FILE__)&#8221; did.</p>
<p>dirname() is a PHP function which returns the directory name of a file. For example if file abc.txt was in &#8220;/tmp/abc.txt&#8221; then the dirname() function would return &#8220;/tmp&#8221; .</p>
<p>Example Usage;</p>
<p><code>&lt;?php</code></p>
<p>$file = &#8220;/tmp/abc.txt&#8221;;</p>
<p>$path = dirname($file); // $path will now contain /tmp</p>
<p>?&gt;</p>
<p>What does dirname(__FILE__) and basename(dirname(__FILE__)) do then?</p>
<p>The __FILE__ constantÂ  represents the running script. It will return the full path and file name of the running script. For example, theÂ  __FILE__ constantÂ  on my server would return &#8220;/var/www/html/index.php&#8221; for my index.php file which is in the &#8220;/var/www/html/&#8221; directory.</p>
<p>The basename() command is normally used in conjunction with the dirname() function to strip the parent directory from a full file name. For example &#8220;/var/www/html/abc.txt&#8221; when passed through basename() would return abc.txt. basename() also works on directories. So, basename() on &#8220;/var/www/html&#8221; would return &#8220;html&#8221; since in Linux directories are files.</p>
<p>Example Usage;</p>
<p>Imagine __FILE__ represents /var/www/html/index.php</p>
<p><code>&lt;?php</code></p>
<p>echo dirname(__FILE__); // returns /var/www/html</p>
<p>echo basename(__FILE__); //returns index.php</p>
<p>echo basename(dirname(__FILE__)); //returns html</p>
<p>?&gt;</p>
<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:50px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fthedaneshproject.com%2Fposts%2Fwhat-does-dirname__file__-and-basenamedirname__file__-do%2F&amp;layout=button_count&amp;show_faces=false&amp;width=50&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_google1" style="width:px;">
					<div class="g-plusone" data-size="medium" data-href="http://thedaneshproject.com/posts/what-does-dirname__file__-and-basenamedirname__file__-do/" ></div>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="What does dirname(__FILE__) and basename(dirname(__FILE__)) do?" data-url="http://thedaneshproject.com/posts/what-does-dirname__file__-and-basenamedirname__file__-do/" 
						data-via=""  ></a> 
				</div></div>
		<div style="clear:both;"></div>Similar Posts:<ul><li><a href="http://thedaneshproject.com/posts/how-to-execute-linux-commands-from-windows/" rel="bookmark" title="July 29, 2008">How To Execute Linux commands from Windows</a></li>

<li><a href="http://thedaneshproject.com/posts/more-xwilling-than-meets-the-eye/" rel="bookmark" title="November 15, 2007">More XWilling than meets the eye&#8230;</a></li>

<li><a href="http://thedaneshproject.com/posts/extract-rar-files-in-linux/" rel="bookmark" title="August 15, 2007">Extract rar files in Linux</a></li>

<li><a href="http://thedaneshproject.com/posts/linux-tip-2-get-your-pid-with/" rel="bookmark" title="March 17, 2009">Linux Tip #2: Get your PID with $$</a></li>

<li><a href="http://thedaneshproject.com/posts/box-net-via-webdav-on-fedora-16/" rel="bookmark" title="February 1, 2012">Box.net via WebDAV on Fedora 16</a></li>
</ul><!-- Similar Posts took 2.930 ms -->]]></content:encoded>
			<wfw:commentRss>http://thedaneshproject.com/posts/what-does-dirname__file__-and-basenamedirname__file__-do/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

