<?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>Full On Design &#187; Coding</title>
	<atom:link href="http://www.fullondesign.co.uk/category/coding/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fullondesign.co.uk</link>
	<description>Design &#38; Web Technologies</description>
	<lastBuildDate>Mon, 21 Jun 2010 16:45:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to use the Filter Functions in PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/1456-how-to-use-the-filter-functions-in-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1456-how-to-use-the-filter-functions-in-php.htm#comments</comments>
		<pubDate>Mon, 21 Jun 2010 16:44:58 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1456</guid>
		<description><![CDATA[When I started learning PHP (Back in the PHP4 days) validating data was always a pain (for me at least). Most of the resources available cited the POSIX functions as the most effective way of validating an email address or URL. Thankfully since then, the PHP community has embraced the PCRE functions which are more efficient and [...]]]></description>
			<content:encoded><![CDATA[<p>When I started learning PHP (Back in the PHP4 days) validating data was always a pain (for me at least). Most of the resources available cited the <a href="http://uk3.php.net/manual/en/ref.regex.php">POSIX functions</a> as the most effective way of validating an email address or URL.</p>
<p>Thankfully since then, the PHP community has embraced the <a href="http://uk3.php.net/manual/en/ref.pcre.php">PCRE functions</a> which are more efficient and are Perl-compatible. However the downside to PCRE (and POSIX for that matter) is that you need to know <a href="http://en.wikipedia.org/wiki/Regular_expression">regular expressions</a>, which for a newbie to learn can feel like walking through a minefield.</p>
<p>Recently though the <a href="http://www.php.net/manual/en/ref.filter.php">Filter Functions</a> have become a very popular method to validate data. This is due to their small learning curve.</p>
<h3>How to use the Filter Functions</h3>
<p>In this example (Using the <a href="http://www.php.net/manual/en/function.filter-var.php">filter_var()</a> function) the filter function takes the data you input (For example: email@example.com) and will return either the data (if it&#8217;s valid) or false (if the data is not valid).</p>
<p><span id="more-1456"></span></p>
<p>
<pre class="brush: php;">&lt;?php
// Filter an Email Address
var_dump(filter_var('email@example.com', FILTER_VALIDATE_EMAIL)); // Returns: string(17) &quot;email@example.com&quot;

// This is a fake email being filtered.
var_dump(filter_var('fake_mail.com', FILTER_VALIDATE_EMAIL)); // Returns: bool(false)

var_dump(filter_var('ema(i)l@e\xample.com', FILTER_SANITIZE_EMAIL )); // Returns: string(17) &quot;email@example.com&quot;

// Filter a URL
var_dump(filter_var('example.com', FILTER_VALIDATE_URL)); // Returns: bool(false)

// Filter a URL
var_dump(filter_var('http://example.com', FILTER_VALIDATE_URL)); // Returns: string(18) &quot;http://example.com&quot;

// Example usage
$email = 'email@example.com'; // or something submitted from a form.
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ // If this returns false
	die('The email you send is invalid.');
}
?&gt;</pre>
</p>
<p>A handful of the useful <a href="http://www.php.net/manual/en/filter.filters.php">available filters</a> are:</p>
<ul>
<li>FILTER_SANITIZE_STRING &#8211; Removes HTML tags and possibly unwanted characters.</li>
<li>FILTER_SANITIZE_EMAIL &#8211; Removes unwanted characters from an email address.</li>
<li>FILTER_SANITIZE_URL &#8211; Removes unwanted characters from a URL.</li>
<li>FILTER_SANITIZE_NUMBER_INT &#8211; Returns only digits,  + and -.</li>
<li>FILTER_VALIDATE_INT &#8211; If data is not an integer it will return false.</li>
<li>FILTER_VALIDATE_URL &#8211; If data is not a URL it will return false.</li>
<li>FILTER_VALIDATE_EMAIL &#8211; If data is not an email it will return false.</li>
<li>FILTER_VALIDATE_IP- If data is not an IP it will return false.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1456-how-to-use-the-filter-functions-in-php.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apparently the new Google Chrome is fast&#8230;</title>
		<link>http://www.fullondesign.co.uk/coding/browsers/1420-apparently-the-new-google-chrome-is-fast.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/browsers/1420-apparently-the-new-google-chrome-is-fast.htm#comments</comments>
		<pubDate>Fri, 07 May 2010 10:20:51 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Browsers]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1420</guid>
		<description><![CDATA[Google Chrome is well known for being very fast at rendering web pages, but based on an update on the Google Student Blog it appears to be mind bogglingly snappy. To give you a sense of how snappy, take a look at this video comparing Chromes rendering to the speed to a potato. Crazy Right? Well it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Google Chrome is well known for being very fast at rendering web pages, but based on an update on the <a href="http://googleforstudents.blogspot.com/2010/05/chrome-and-browser-speed-tests-potato.html">Google Student Blog</a> it appears to be mind bogglingly snappy. To give you a sense of how snappy, take a look at this video comparing Chromes rendering to the speed to a potato.</p>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/nCgQDjiotG0&#038;hl=en_GB&#038;fs=1&#038;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/nCgQDjiotG0&#038;hl=en_GB&#038;fs=1&#038;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p>Crazy Right? Well it&#8217;s all down to a new <a href="http://code.google.com/p/v8/">V8 JavaScript rendering engine</a>, which boasts an improvement of 35%.</p>
<p><span id="more-1420"></span></p>
<h3>That&#8217;s great! What does it mean for Web Development?</h3>
<p>Hopefully this new engine will inspire other browser programmers how to render JavaScript faster, which in 3-6 months should mean the average user experience (the 35% of users who  upgrade their browser when updates are released) should be improved.</p>
<p>However, this does not mean we can use create complex JavaScript websites (Such as Facebook) render quickly, instead it means <a href="http://dzineblog.com/2008/03/10-websites-that-use-javascript-animation-effectively.html">subtle usability improvements</a> to a web page should be more effective.</p>
<p><em>Note: Is anyone interested in trying to recreate this but showing other browsers loading?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/browsers/1420-apparently-the-new-google-chrome-is-fast.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bypass Facebook&#8217;s &#8220;Like this to see the picture&#8221; pages using Google Chrome</title>
		<link>http://www.fullondesign.co.uk/coding/xhtml_and_css/1406-bypass-facebooks-like-this-to-see-the-picture-pages-using-google-chrome.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/xhtml_and_css/1406-bypass-facebooks-like-this-to-see-the-picture-pages-using-google-chrome.htm#comments</comments>
		<pubDate>Thu, 22 Apr 2010 22:48:54 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[XHTML & CSS]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1406</guid>
		<description><![CDATA[This is a quick video I made on bypassing those annoying Facebook &#8220;Like/become a fan of this to see the picture&#8221; pages. View on YouTube This video makes use of Google Chrome&#8217;s Developer Tools which allows you to edit CSS/HTML in real-time on a web page. Update: If you use Greasemonkey the Facebook Like Bypass script will [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick video I made on bypassing those annoying Facebook &#8220;Like/become a fan of this to see the picture&#8221; pages.</p>
<p style="text-align: center;"><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/v7bn4DlLF9E&#038;hl=en_GB&#038;fs=1&#038;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/v7bn4DlLF9E&#038;hl=en_GB&#038;fs=1&#038;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object><br />
<a href="http://www.youtube.com/watch?v=v7bn4DlLF9E">View on YouTube </a></p>
<p>This video makes use of Google Chrome&#8217;s Developer Tools which allows you to edit CSS/HTML in real-time on a web page.</p>
<p><em>Update: If you use Greasemonkey the <a href="http://userscripts.org/scripts/show/76287">Facebook Like Bypass</a> script will do the above for you.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/xhtml_and_css/1406-bypass-facebooks-like-this-to-see-the-picture-pages-using-google-chrome.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>URL Shortening Function</title>
		<link>http://www.fullondesign.co.uk/coding/php/1319-url-shortening-function.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1319-url-shortening-function.htm#comments</comments>
		<pubDate>Fri, 08 Jan 2010 23:20:02 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1319</guid>
		<description><![CDATA[Here is a function I use from time to time in my code which I thought I should share. It allows you to quickly shorten URL&#8217;s via 6 popular URL shortening websites. function shorten_url($url, $service=NULL){ if($service== 'tinyurl'){return get_link('http://tinyurl.com/api-create.php?url='.urlencode($url));} elseif($service == 'urly'){return get_link('http://ur.ly/new.txt?href='.urlencode($url));} elseif($service == 'isgd'){return get_link('http://is.gd/api.php?longurl='.urlencode($url));} elseif($service == 'klam'){return get_link('http://kl.am/api/shorten/?format=text&#38;url='.urlencode($url));} elseif($service == 'unu'){return get_link('http://u.nu/unu-api-simple?url='.urlencode($url));} else{return [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a function I use from time to time in my code which I thought I should share. It allows you to quickly shorten URL&#8217;s via 6 popular URL shortening websites.</p>
<pre class="brush: php;">
function shorten_url($url, $service=NULL){
		if($service== 'tinyurl'){return get_link('http://tinyurl.com/api-create.php?url='.urlencode($url));}
		elseif($service == 'urly'){return get_link('http://ur.ly/new.txt?href='.urlencode($url));}
		elseif($service == 'isgd'){return get_link('http://is.gd/api.php?longurl='.urlencode($url));}
		elseif($service == 'klam'){return get_link('http://kl.am/api/shorten/?format=text&amp;url='.urlencode($url));}
		elseif($service == 'unu'){return get_link('http://u.nu/unu-api-simple?url='.urlencode($url));}
		else{return get_link('http://api.tr.im/v1/trim_simple?url='.urlencode($url));}
		return $url;
	}

	function get_link($url){
		if(function_exists('curl_init')){
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_VERBOSE, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			//curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
			//curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_URL, $url);
			$result = curl_exec($ch);
			$resultArray = curl_getinfo($ch);
			if ($resultArray['http_code'] == 200){
				return $result;
			} else {
				return FALSE;
			}
			curl_close($ch);
		}elseif(ini_get('allow_url_fopen') == 1){
			return fopen($url, 'r');
		}
		return FALSE;
	}

/* Usage */
echo shorten_url('http://www.fullondesign.co.uk/');
// returns: http://tr.im/JPCz
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1319-url-shortening-function.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
