<?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>nhaskins.com &#187; include()</title>
	<atom:link href="http://nhaskins.com/tag/include/feed/" rel="self" type="application/rss+xml" />
	<link>http://nhaskins.com</link>
	<description>web development note book</description>
	<lastBuildDate>Thu, 17 May 2012 13:18:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>D.R.Y. out those useful PHP scripts</title>
		<link>http://nhaskins.com/post/d-r-y-out-those-useful-php-scripts/</link>
		<comments>http://nhaskins.com/post/d-r-y-out-those-useful-php-scripts/#comments</comments>
		<pubDate>Tue, 11 May 2010 13:33:39 +0000</pubDate>
		<dc:creator>Nathan Haskins</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[idea]]></category>
		<category><![CDATA[include()]]></category>
		<category><![CDATA[open_dir()]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[scandir()]]></category>

		<guid isPermaLink="false">http://nhaskins.com/post/d-r-y-out-those-useful-php-scripts/</guid>
		<description><![CDATA[D.R.Y. &#8211; &#8216;Don&#8217;t repeat yourself&#8217; I have a few PHP scripts that come in handy on a lot of different sites. The issue I ran into was that if i needed to make an update to one of these useful scripts, I&#8217;d have to go find all instances of that script, and update them across [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/020161622X/ref=pd_lpo_k2_dp_sr_1?pf_rd_p=486539851&amp;pf_rd_s=lpo-top-stripe-1&amp;pf_rd_t=201&amp;pf_rd_i=0974514012&amp;pf_rd_m=ATVPDKIKX0DER&amp;pf_rd_r=0ZHMBPHWDTM42C4BEBAN">D.R.Y. &#8211; &#8216;Don&#8217;t repeat yourself&#8217; </a></p>
<p>I have a few PHP scripts that come in handy on a lot of different sites.  The issue I ran into was that if i needed to make an update to one of these useful scripts, I&#8217;d have to go find all instances of that script, and update them across many domains.</p>
<p>There&#8217;s ways of doing this with ninja SED/grep styles.  But a better way may to be make a folder just below the domains directory, and include files from that directory as needed.</p>
<p>In the example below im stepping backwards from the public html directory into my scripts directory.</p>
<pre><code>include('../../../phpIncludes/test.php');</code></pre>
<p>Thats about the extent of it, and im sure this can be cleaned up a bit.  I was using the scandir() function to find my way to the proper path by echoing out the files of the current directory.</p>
<p>I was also reading open_dir() can cause issues with this technique, and if open_dir() is active it can php scripts from editing lower than the domains&#8217;s root.  open_dir() is a good safety net, but is also prevents some tricks and techniques that just need to happen. A good example is in WordPress sites (as of 2.9) the Media library will throw errors with open_dir() enabled.</p>
]]></content:encoded>
			<wfw:commentRss>http://nhaskins.com/post/d-r-y-out-those-useful-php-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

