<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Doing My Best... a Web Developers Blog</title>
	
	<link>http://www.iwilldomybest.com</link>
	<description>Ranging from PHP &amp; MySQL to Random Crap from the internet, I got it all here.</description>
	<lastBuildDate>Sun, 31 Jan 2010 01:46:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/DoingMyBestAWebDevelopersBlog" /><feedburner:info uri="doingmybestawebdevelopersblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>PHP Tip: Handling Form Data</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/LAw9Y0H6U6o/</link>
		<comments>http://www.iwilldomybest.com/2010/01/php-tip-handling-form-data/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 01:45:41 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=94</guid>
		<description><![CDATA[One of the most common tasks of a Web Dev, has down, is handling form data. As a web developer you'll create hundreds of forms and in turn, write hundreds of pieces of code to handle your form data. Early on this became the worse part of my job. So I've create a super quick [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most common tasks of a Web Dev, has down, is handling form data. As a web developer you'll create hundreds of forms and in turn, write hundreds of pieces of code to handle your form data.<br />
<span id="more-94"></span><br />
Early on this became the worse part of my job. So I've create a super quick way to handle post data:</p>
<pre>

$valid = true; //innocent until proven guilty
$errors = array(); // errors array
$clean = array();

foreach($_POST as $key => $val)
{
	switch($key)
	{
		case 'first_name':
			// do validation
			if(validateString($val) == false)
			{
				$valid = false; // we're no longer valid.
				$errors[] = "You're missing your first name!"; // prime up an error message for our user
			}
			else
			{
				$clean[$key] = $val;
			}
			break;
		case 'last_name':
			// do validation
			break;
	}
}

if($valid == false)
{
	// show the form again, but with the error message
}
else
{
	// handle our clean array anyway we want (usually a DB insert)
}

?>
</pre>

<p><a href="http://feedads.g.doubleclick.net/~a/4-k9sFmLLXn5kno6PNil-vjH67M/0/da"><img src="http://feedads.g.doubleclick.net/~a/4-k9sFmLLXn5kno6PNil-vjH67M/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/4-k9sFmLLXn5kno6PNil-vjH67M/1/da"><img src="http://feedads.g.doubleclick.net/~a/4-k9sFmLLXn5kno6PNil-vjH67M/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/LAw9Y0H6U6o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2010/01/php-tip-handling-form-data/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2010/01/php-tip-handling-form-data/</feedburner:origLink></item>
		<item>
		<title>Q&amp;A: Which Framework Should I Use?</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/HI_rTuOAoeI/</link>
		<comments>http://www.iwilldomybest.com/2009/09/qa-which-framework-should-i-use/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 11:31:40 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=92</guid>
		<description><![CDATA[Q: Which Framework Should I Use to make &#60;blank&#62; ? A: You're already off on the wrong foot. The reason? You're thinking you need a framework to get whatever you need done. All too often I see posts on forums or on IRC: "What framework should I use for a large networking site, like MySpace?" [...]]]></description>
			<content:encoded><![CDATA[<p>Q: Which Framework Should I Use to make &lt;blank&gt; ?</p>
<p>A: You're already off on the wrong foot. The reason? You're thinking you need a framework to get whatever you need done.<br />
<span id="more-92"></span><br />
All too often I see posts on forums or on IRC: "What framework should I use for a large networking site, like MySpace?"</p>
<p>1) Comon, MySpace? Ugh.</p>
<p>2) If you have to ask, you're doing it wrong.</p>
<p>3) This question will spawn a thread of everyone promoting their own personal frameworks. E-Peen war ensues.</p>
<p>You're asking the wrong question. Some better questions might be:<br />
"Is there a particular framework that out performs another?"<br />
"How is performance gauged?"<br />
"Does it allow Master to Slave databases?"<br />
"Does it support Memcache?"<br />
"What kind of templating system does it use?"<br />
"What's the ease of development?"</p>
<p>As you drill further and further down into these questions, you're going to discover you will have to start making comprimises.</p>
<p>Some frameworks eat up less CPU, but does that mean it out performs?<br />
For a large "networking site" you'll need hundreds of database servers, so really, does any framework handle that many "out of the box" ?<br />
If you go, "Memcache - what's that?" - then you're already set up for fail. If you find a framework that does support clusters of MC servers, will it allow you to tailor it to your needs?<br />
As far as templating systems go, generic Smarty won't cut it. You'll need to hack, strip and extend Smarty into all sorts of weird specific configurations for optimal performance.<br />
Ease of development? Does it work well for you? How long will it take to hack your framework into a better performing set up? How much effort goes into training new devs on the project?</p>
<p>You're going to find yourself coming to a realization: You need to put in a lot of work.</p>
<p>Reaching out for a framework is a common misconception of Jr Developers. It's easy to grab for these frameworks beacuse you don't really understand what they do.</p>
<p>Don't get me wrong, some of the frameworks out there are great. And not every project requires custom built frameworks.</p>
<p>But there's two different leagues here. While you're playing in the minors - have fun with your frameworks, use Zend, CI, Symphony, what have you.</p>
<p>When it comes time to play in the big leagues, leave your AA and AAA crap at the door.</p>
<p>There's a difference between sites that serve 1 M Unique users a month, and those that serve over 10 M unique users a day, and that difference is not found in a box, or "off the shelve."</p>

<p><a href="http://feedads.g.doubleclick.net/~a/dZxz6CkfQAXHA7dV5VLNyYvfyfA/0/da"><img src="http://feedads.g.doubleclick.net/~a/dZxz6CkfQAXHA7dV5VLNyYvfyfA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/dZxz6CkfQAXHA7dV5VLNyYvfyfA/1/da"><img src="http://feedads.g.doubleclick.net/~a/dZxz6CkfQAXHA7dV5VLNyYvfyfA/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/HI_rTuOAoeI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2009/09/qa-which-framework-should-i-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2009/09/qa-which-framework-should-i-use/</feedburner:origLink></item>
		<item>
		<title>Make an Impact</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/9VW_eiEsAI0/</link>
		<comments>http://www.iwilldomybest.com/2009/06/make-an-impact/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 08:36:11 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Personal Life]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[impact]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=86</guid>
		<description><![CDATA[Day 3, you better have your shit together, and you should be swinging for the fences. ]]></description>
			<content:encoded><![CDATA[<p>Recently, it has come to my attention that not all developers have the ability to make an impact.</p>
<p>But that begs the question, what does making an impact mean?</p>
<p>Making an impact.</p>
<p>It's coming out the door - swinging. So much of a developers role, especially in a start up, is determined by their first 3 days. Day 1, yes, come in, settle down, welcome aboard. Day 2, start asking all of the questions you had from day 1, and for heavens sake, do something besides look busy.</p>
<p>Day 3, you better have your shit together, and you should be swinging for the fences.</p>
<p>Don't ask for something to do, demand a project. And while you're doing, don't ask questions the very second you think you don't know something.</p>
<p>Look for the answer first.</p>
<p>It's this mentality that I find so damn frustrating - all of the answers should be in the code base. Run a damn grep on your project base, and find an answer. There's no excuse for any mid, to upper mid level programmer to be asking stupid questions. By stupid question, I'm refering to in the inabilty to traverse the code base in search of functions, methods, answers.</p>
<p>Make an impact, 3 days.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/lquz32EoqJBrAxosZbXbon0RK_I/0/da"><img src="http://feedads.g.doubleclick.net/~a/lquz32EoqJBrAxosZbXbon0RK_I/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/lquz32EoqJBrAxosZbXbon0RK_I/1/da"><img src="http://feedads.g.doubleclick.net/~a/lquz32EoqJBrAxosZbXbon0RK_I/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/9VW_eiEsAI0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2009/06/make-an-impact/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2009/06/make-an-impact/</feedburner:origLink></item>
		<item>
		<title>Someone Failed to Inform Me</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/C-UViRDG604/</link>
		<comments>http://www.iwilldomybest.com/2009/02/someone-failed-to-inform-me/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 10:16:39 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[Personal Life]]></category>
		<category><![CDATA[Work Life]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[zynga]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=82</guid>
		<description><![CDATA[Someone apparently failed to inform me that the video game industry is freaking crazy. And I love it I've recently started working at Zynga , and I couldn't be happier. What this mean though, is that there will be fewer and fewer blog posts about programming related issues. Instead, I'll try to focus on theory [...]]]></description>
			<content:encoded><![CDATA[<p>Someone apparently failed to inform me that the video game industry is freaking crazy.</p>
<p>And I love it <img src='http://www.iwilldomybest.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I've recently started working at <a href="http://www.zynga.com" target="_blank">Zynga </a>, and I couldn't be happier.</p>
<p>What this mean though, is that there will be fewer and fewer blog posts about programming related issues. Instead, I'll try to focus on theory rather than implimentation.</p>
<p>Until then, everyone should feel free to head over to zynga and try some games <img src='http://www.iwilldomybest.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/2h5vucICdZXvOexYViyJGzy2h-k/0/da"><img src="http://feedads.g.doubleclick.net/~a/2h5vucICdZXvOexYViyJGzy2h-k/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/2h5vucICdZXvOexYViyJGzy2h-k/1/da"><img src="http://feedads.g.doubleclick.net/~a/2h5vucICdZXvOexYViyJGzy2h-k/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/C-UViRDG604" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2009/02/someone-failed-to-inform-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2009/02/someone-failed-to-inform-me/</feedburner:origLink></item>
		<item>
		<title>Modrewrite and Short Urls – What you really want to know.</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/P_fGNDuWKCQ/</link>
		<comments>http://www.iwilldomybest.com/2009/01/modrewrite-and-short-urls-htaccess-file-tip/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 11:07:44 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod rewrite]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=77</guid>
		<description><![CDATA[I recently opened up an old .htaccess and I was struck with the memory of how much it sucked trying to Google search for some real, working, answers on making short urls. So here you go, my quick tip on what you really want to know about mod_rewrite. If you want an actual explanation of [...]]]></description>
			<content:encoded><![CDATA[<p>I recently opened up an old <a title="WikiPedia - Htaccess" href="http://en.wikipedia.org/wiki/Htaccess" target="_blank">.htaccess</a> and I was struck with the memory of how much it sucked trying to Google search for some real, working, answers on making short urls.</p>
<p>So here you go, my quick tip on what you really want to know about <a title="ApacheDocs - Mod_rewrite" href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" target="_blank">mod_rewrite</a>.</p>
<p><span id="more-77"></span></p>
<p>If you want an actual explanation of what is going on here it's at the bottom.</p>
<p><strong>Solution 1:</strong></p>
<p><code>File: .htaccess</code></p>
<pre>Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) /index.php [L]</pre>
<p><code>File: index.php</code><br />
<code><br />
&lt;?php<br />
$urlArray = explode("/",$_SERVER['REQUEST_URI']);<br />
array_shift($urlArray); // Gets rid of the blank first param.<br />
?&gt;<br />
</code></p>
<p>Now you have an array with all of your parts, and you can map them accordingly.</p>
<p><strong>Solution 1.a (more elegant):</strong><br />
<code>File: .htaccess</code></p>
<pre>&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
&lt;/IfModule&gt;</pre>
<p>That version just checks to make sure the module is installed.</p>
<p><strong>Solution 2:</strong><br />
If you have just a couple of pages that you want to look prettier:</p>
<p><code>File: .htaccess</code></p>
<pre>Options +FollowSymLinks
RewriteEngine on
RewriteRule ^home$ index.php
RewriteRule ^about$ about.php</pre>
<p>And you just keep adding <code>RewriteRule</code>'s for each page. This is really only helpful when you just have a set of static looking pages for a site.</p>
<p><strong>Explanation:</strong></p>
<dl>
<dt>Options +FollowSymLinks</dt>
<dd>Tells Apache to follow sym links (usually on anyways...)</dd>
<dt>RewriteEngine on</dt>
<dd>Tells apache to turn on the RewriteEngine for this folder</dd>
<dt>RewriteCond %{REQUEST_FILENAME} !-f</dt>
<dd>Read this as: Condtion, If the file we're requesting is not a file...</dd>
<dt>RewriteCond %{REQUEST_FILENAME} !-d</dt>
<dd>Read this as: Condtion, If the file we're requesting is not a directory...</dd>
<dt>RewriteRule . /index.php [L]</dt>
<dd>Then Rewrite this url to index.php ([L] forces it to be the last redirect)</dd>
</dl>

<p><a href="http://feedads.g.doubleclick.net/~a/CgLtbH2hXA6wt3eXQ6ZTM6kUGk4/0/da"><img src="http://feedads.g.doubleclick.net/~a/CgLtbH2hXA6wt3eXQ6ZTM6kUGk4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/CgLtbH2hXA6wt3eXQ6ZTM6kUGk4/1/da"><img src="http://feedads.g.doubleclick.net/~a/CgLtbH2hXA6wt3eXQ6ZTM6kUGk4/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/P_fGNDuWKCQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2009/01/modrewrite-and-short-urls-htaccess-file-tip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2009/01/modrewrite-and-short-urls-htaccess-file-tip/</feedburner:origLink></item>
		<item>
		<title>Professional PHP</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/mi_y8Ky-2eE/</link>
		<comments>http://www.iwilldomybest.com/2009/01/professional-php/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 16:05:18 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=61</guid>
		<description><![CDATA[It's important to remember what sets a professional PHP developer apart from the pack that floods your average help channel. Too often I run into reviewing or helping a "professional" developer, and I can't help but mutter "you're doing it wrong..." I feel the most important attribute that separates one developer from another is when [...]]]></description>
			<content:encoded><![CDATA[<p>It's important to remember what sets a professional PHP developer apart from the pack that floods your average help channel.</p>
<p>Too often I run into reviewing or helping a "professional" developer, and I can't help but mutter "you're doing it wrong..."</p>
<p><span id="more-61"></span></p>
<p>I feel the most important attribute that separates one developer from another is when they write for usability and maintainability.</p>
<p>So let's take a look at some extremely simple steps you can take to make your project's code more flexible.</p>
<p>1. For the love of all that there is, seperate your header and footer files. Yes, I'm still seeing this happen, often. All content that is above your generated page needs to go into a header file, and all the content below it into a footer file. So when you need to modify one line, you do it only once.</p>
<pre>&lt;?php
require_once(dirname(__FILE__).'/includes/header.php');
?&gt;
&lt;div id='content'&gt;
&lt;?php
	// script runs
?&gt;
&lt;/div&gt;
&lt;?php
require_once(dirname(__FILE__).'/includes/footer.php');
?&gt;</pre>
<p>2. Create a function to generate your navigation. And when I say generate, I mean you give it some flexibility as well. This can be done even with the smallest of sites. Example:</p>
<pre>&lt;?php
$site_pages = array();
$site_pages[] = array('text' =&gt; 'home', 'link' =&gt; 'home.php');
$site_pages[] = array('text' =&gt; 'about', 'link' =&gt; 'about.php');
$site_pages[] = array('text' =&gt; 'partner', 'link' =&gt; 'http://www.example.domain.com/');

function buildNav($links)
{
	$output = '';
	foreach($links as $page)
	{
		$output .= "&lt;a href=\"{$page['link']}\" title=\"{$page['text']}\"&gt;{$page['text']}&lt;/a&gt;\n";
	}
 	return $output;
}
?&gt;</pre>
<p>The example above could easily be modified to allow optional values to the array, like <code>'enabled' =&gt; false</code> to turn off a link. Or you could define a link "template", and use <code>str_replace()</code> to substitute values.</p>
<p>This means if you, or the customer (with any know how) can quickly update the links at any time. For more advanced sites/projects this can obviously become more complicated, but it saves even more time.</p>
<p>3. If you're not going to use OOP, at least use functions. Any common task or specific sequence should be placed in it's own function. An example would be our navigation function from #2. Another example would be running a query for a specific item. If you ever need to modify your table structure you'll regret having to hunt down all of your inline queries.</p>
<p>4. When you create 'admin' features, take the 5 minutes to create a function that actually checks if the person accessing that "super hidden" directory filled with scripts that just accept anything.</p>
<p>I've seen this happen even on large global community sites.</p>
<p>Some developers will stuff their admin scripts in a folder such as /admin/, and just assume that if data is posted there then it's ok.</p>
<p>The least you should do is place a session check, and place it in a function.</p>
<pre>&lt;?php
function isAdmin()
{
	if(!isset($_SESSION['user_name']) || !isset($_SESSION['user_id']))
	{
		return false;
	}
	else
	{
		$sql = "SELECT COUNT(*) as cnt FROM user_table WHERE user_id = ".intval($_SESSION['user_id']);
		// do the query, check it, etc.
		return true;
	}
}
?&gt;</pre>
<p>Then when it comes time to run your script, simply:</p>
<pre>&lt;?php
if(isAdmin() === false)
{
	die('Log back in');
}
?&gt;</pre>
<p>5. Create a wrapper for handling escape strings. If you're not using a database class (like PDO) to handle this, you'll need to do this.</p>
<p>Just assume that your client could have their PHP configuration change, or they change hosts, or any possible combination of changes take place.</p>
<p>Create a simple wrapper that will check of magic quotes, and escape for your database insert.</p>
<pre>&lt;?php
function cleanString($input)
{
	if(get_magic_quotes_gpc())
	{
		$input = stripslashes($input);
	}
	$output = mysql_real_escape_string(trim($input));

	return $output;
}
?&gt;</pre>
<p>6. Create a configuration file so you can update common yet critical variables. An example of this would be paths. Your system quickly gains adaptability if you just create a defines.php file, and place in there your simple variables.</p>
<p>The overall approach you should have to any project you take is that you should use an establish tool chain you have developed. It doesn't take much time or effort to create a simple set of classes that can handle just about any thing you need to create. If you wish to use functions, you can do the same. The idea is that you write once, and write it in such a manner that you can tweak it later on.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/DYtXW2K5wrq9XxUvpXRjd92iTdw/0/da"><img src="http://feedads.g.doubleclick.net/~a/DYtXW2K5wrq9XxUvpXRjd92iTdw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/DYtXW2K5wrq9XxUvpXRjd92iTdw/1/da"><img src="http://feedads.g.doubleclick.net/~a/DYtXW2K5wrq9XxUvpXRjd92iTdw/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/mi_y8Ky-2eE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2009/01/professional-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2009/01/professional-php/</feedburner:origLink></item>
		<item>
		<title>Google Speaks on Net Neutrality and Benefits of caching</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/78sg2CKV_kk/</link>
		<comments>http://www.iwilldomybest.com/2008/12/google-speaks-on-net-neutrality-and-benefits-of-caching/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 04:15:13 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[cdn]]></category>
		<category><![CDATA[edge]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[net]]></category>
		<category><![CDATA[neutrality]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=69</guid>
		<description><![CDATA[In this post on the google blog,http://googleblog.blogspot.com/2008/12/net-neutrality-and-benefits-of-caching.html , Google speaks about how people are confused on the net neutrality and the use of edge caching. I find it interesting that someone could take the usage of CDN's as an act of an un neutral  web. The act of handling certain traffic as more important than [...]]]></description>
			<content:encoded><![CDATA[<p>In this post on the google blog,<a title="http://googleblog.blogspot.com/2008/12/net-neutrality-and-benefits-of-caching.html" href="http://googleblog.blogspot.com/2008/12/net-neutrality-and-benefits-of-caching.html" target="_blank">http://googleblog.blogspot.com/2008/12/net-neutrality-and-benefits-of-caching.html</a> , Google speaks about how people are confused on the net neutrality and the use of edge caching.</p>
<p>I find it interesting that someone could take the usage of CDN's as an act of an un neutral  web.</p>
<p>The act of handling certain traffic as more important than other traffic is the act of an un neutral web. Developers should consider these words carefully.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/MruZzfouUnzivA7XvzEfUKMSVUQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/MruZzfouUnzivA7XvzEfUKMSVUQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/MruZzfouUnzivA7XvzEfUKMSVUQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/MruZzfouUnzivA7XvzEfUKMSVUQ/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/78sg2CKV_kk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/12/google-speaks-on-net-neutrality-and-benefits-of-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/12/google-speaks-on-net-neutrality-and-benefits-of-caching/</feedburner:origLink></item>
		<item>
		<title>Screen Scraping made too easy</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/exHmjufJ1_Y/</link>
		<comments>http://www.iwilldomybest.com/2008/12/screen-scraping-made-too-easy/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 08:40:27 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[screen scrape]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=63</guid>
		<description><![CDATA[Recently I had some free time and I decided I wanted to automate some common tasks of mine. And let me tell you honestly, I hate having to do screen scraping. It's an annoying, tedious task. Making regex for this, and for that, and then to find out my hours were wasted as that regex [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had some free time and I decided I wanted to <a title="WikiPedia - Automation" href="http://en.wikipedia.org/wiki/Automation" target="_blank">automate</a> some common tasks of mine. And let me tell you honestly, I hate having to do screen scraping. It's an annoying, tedious task. Making regex for this, and for that, and then to find out my hours were wasted as that regex won't work on another site.</p>
<p>That's a thing of the past.</p>
<p><span id="more-63"></span></p>
<p>I'm super excited about this find. Maybe I'm the last to discover it, but it's just too awesome to pass up.</p>
<p>The project is called: <a title="PHP Simple HTML DOM Parser" href="http://simplehtmldom.sourceforge.net/" target="_blank">PHP Simple HTML DOM Parser</a>.</p>
<p>Literally, this takes almost all of the magic out of screen scraping. Here's an example from a quick and dirty login and grab my stats for <a title="e-Sports Entertainment" href="http://esportsea.com" target="_blank">ESEA</a>.</p>
<pre>require_once('simple_html_dom.php'); // get our class

define('COOKIE_JAR','./cookie/cookie'); // cookie jar for cURL
/**
* We need to set up our referrer and user agent, for cURL
**/
$referrer = "http://www.esportsea.com/";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4";
/**
* str = our direct link to our user page
**/
$str = "http://www.esportsea.com/users/&lt;your user id&gt;";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$str);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_REFERER, $referrer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_JAR);
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_JAR);
curl_setopt($ch, CURLOPT_TIMEOUT, '10');
$result = curl_exec ($ch);
curl_close ($ch);
// done with cURL
$html = new simple_html_dom(); // create our HTML object

$html-&gt;load($result);

$pug_stats = $html-&gt;find('#body-matches-pug table tr'); // load up pug stats

// this loops through each &lt;tr&gt;
$output = array();
foreach($pug_stats as $stat)
{
	$row['game'] 	= trim($stat-&gt;find('img',0)-&gt;title);
	$row['link'] 	= trim($stat-&gt;find('a',0)-&gt;href);
	$row['score']	= trim($stat-&gt;find('a',0)-&gt;plaintext);
	$row['srv'] 	= trim($stat-&gt;find('a',1)-&gt;href);
	$row['srv_txt'] = trim($stat-&gt;find('a',1)-&gt;plaintext);
	$output[] = $row;

}
echo "&lt;pre&gt;",print_r($output,true),"&lt;/pre&gt;";
exit;

?&gt;</pre>
<p>And that's it.</p>
<p>Now take a look at that, and realize how much stuff I'm not forced to do.</p>
<p>I know this isn't some great new invention, loading the source into a DOM object and parsing it, but man, this almost eliminates the need to think about screen scraping entirely.</p>
<p>Enjoy.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/RStpF9XyDKmx3ckxq9x5d6ulAhE/0/da"><img src="http://feedads.g.doubleclick.net/~a/RStpF9XyDKmx3ckxq9x5d6ulAhE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/RStpF9XyDKmx3ckxq9x5d6ulAhE/1/da"><img src="http://feedads.g.doubleclick.net/~a/RStpF9XyDKmx3ckxq9x5d6ulAhE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/exHmjufJ1_Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/12/screen-scraping-made-too-easy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/12/screen-scraping-made-too-easy/</feedburner:origLink></item>
		<item>
		<title>Search Engine Spam Videos</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/l39SrTeki3A/</link>
		<comments>http://www.iwilldomybest.com/2008/10/search-engine-spam-videos/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 18:33:41 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[protect]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=59</guid>
		<description><![CDATA[Some some tweets come in and I headed on over to IM Broadcast saw some Search Engine Spam videos come up. I thought they were pretty interesting to watch, and it was nice to hear from MSN, Google, and Yahoo. It does make me wonder if black hat SEO really does have a chance? Anyways, [...]]]></description>
			<content:encoded><![CDATA[<p>Some some <a title="My Twitter" href="http://www.twitter.com/dschreck" target="_blank">tweets</a> come in and I headed on over to <a title="IM Broadcast" href="http://www.imbroadcast.com" target="_blank">IM Broadcast</a> saw some Search Engine Spam videos come up.</p>
<p>I thought they were pretty interesting to watch, and it was nice to hear from MSN, Google, and Yahoo. It does make me wonder if black hat SEO really does have a chance? <img src='http://www.iwilldomybest.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> </p>
<p>Anyways, here are the direct links to the vids:</p>
<p><a title="Part One" href="http://www.imbroadcast.com/video/53/Search-Engine-Spam-Part-1-Overview" target="_blank">http://www.imbroadcast.com/video/53/Search-Engine-Spam-Part-1-Overview</a></p>
<p><a title="Part Two" href="http://www.imbroadcast.com/video/55/Search-Engine-Spam-Part-2-On-The-Page-Issues" target="_blank">http://www.imbroadcast.com/video/55/Search-Engine-Spam-Part-2-On-The-Page-Issues</a></p>
<p><a title="Part Three" href="http://www.imbroadcast.com/video/54/Search-Engine-Spam-Part-3-Link-Spam--Paid-Links" target="_blank">http://www.imbroadcast.com/video/54/Search-Engine-Spam-Part-3-Link-Spam--Paid-Links</a></p>
<p>Hope you all enjoy.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/iigiAou7PwLGcYlf6uhzrZVswrg/0/da"><img src="http://feedads.g.doubleclick.net/~a/iigiAou7PwLGcYlf6uhzrZVswrg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/iigiAou7PwLGcYlf6uhzrZVswrg/1/da"><img src="http://feedads.g.doubleclick.net/~a/iigiAou7PwLGcYlf6uhzrZVswrg/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/l39SrTeki3A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/10/search-engine-spam-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/10/search-engine-spam-videos/</feedburner:origLink></item>
		<item>
		<title>PHP Reference Card – Failed?</title>
		<link>http://feedproxy.google.com/~r/DoingMyBestAWebDevelopersBlog/~3/R3dw1OXTa7s/</link>
		<comments>http://www.iwilldomybest.com/2008/10/php-reference-card-failed/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 17:48:49 +0000</pubDate>
		<dc:creator>dschreck</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ref card]]></category>
		<category><![CDATA[reference card]]></category>

		<guid isPermaLink="false">http://www.iwilldomybest.com/?p=53</guid>
		<description><![CDATA[While taking a look at my 'Tech Blogs' tab in NetVibes I saw the headline for a reference card available for PHP. So, I hopped on over to dZone.com, got an account (it's free), and downloaded it. I'm not really impressed. I believe the beginner may benefit from this, but there's just so many gaping [...]]]></description>
			<content:encoded><![CDATA[<p>While taking a look at my 'Tech Blogs' tab in <a title="NetVibes" href="http://www.netvibes.com/" target="_blank">NetVibes</a> I saw the headline for a <a title="http://refcardz.dzone.com/refcardz/php?oid=ban00022-15" href="http://refcardz.dzone.com/refcardz/php?oid=ban00022-15" target="_blank">reference card available</a> for PHP. So, I hopped on over to dZone.com, got an account (it's free), and downloaded it.</p>
<p>I'm not really impressed.</p>
<p>I believe the beginner may benefit from this, but there's just so many gaping holes in the reference card... Like what about the GD library? Or perhaps cURL? File handling? XML?</p>
<p>Honestly, how could you call a reference card a PHP Reference Card without the most common uses listed? I think the card may be off to a good start, but please, release a new more complete version soon.</p>
<p>Final Verdict:</p>
<p>While it may be great for beginners, it's still lacking for the rest of us. I'll pass and keep php.net as my reference card.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/u3yk_TzMoBslgLNdjPud8E5PRoM/0/da"><img src="http://feedads.g.doubleclick.net/~a/u3yk_TzMoBslgLNdjPud8E5PRoM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/u3yk_TzMoBslgLNdjPud8E5PRoM/1/da"><img src="http://feedads.g.doubleclick.net/~a/u3yk_TzMoBslgLNdjPud8E5PRoM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/DoingMyBestAWebDevelopersBlog/~4/R3dw1OXTa7s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.iwilldomybest.com/2008/10/php-reference-card-failed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.iwilldomybest.com/2008/10/php-reference-card-failed/</feedburner:origLink></item>
	</channel>
</rss>
