<?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; PHP</title>
	<atom:link href="http://www.fullondesign.co.uk/coding/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fullondesign.co.uk</link>
	<description>Design &#38; Web Technologies</description>
	<lastBuildDate>Sun, 30 Oct 2011 21:37:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PDO (PHP Data Objects) &#8211; Starter Guide</title>
		<link>http://www.fullondesign.co.uk/coding/php/1907-pdo-php-data-objects-starter-guide.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1907-pdo-php-data-objects-starter-guide.htm#comments</comments>
		<pubDate>Fri, 01 Jul 2011 20:14:19 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1907</guid>
		<description><![CDATA[It may surprise you to hear, that using the mysql_connect() function in PHP has recently be marked as &#8220;old hat&#8221; coding because it&#8217;s slow in comparison with newer methods. A better alternative is PDO (PHP Data Objects), a lightweight method for accessing databases. Here is a quick overview to help you get started with PDO. [...]]]></description>
			<content:encoded><![CDATA[<p>It may surprise you to hear, that using the <a href="http://php.net/manual/en/function.mysql-connect.php">mysql_connect()</a> function in PHP has recently be marked as &#8220;old hat&#8221; coding because it&#8217;s slow in comparison with newer methods. A better alternative is <a href="http://php.net/manual/en/book.pdo.php">PDO (PHP Data Objects)</a>, a lightweight method for accessing databases. Here is a quick overview to help you get started with PDO.</p>
<h3>Reasons to use PDO</h3>
<ul>
<li>It&#8217;s Fast - it talks to the database via a database specific PDO-driver.</li>
<li>It&#8217;s Object Oriented &#8211; The methods within the class are the same for each database driver, so you can easily change your database driver without lots of extra coding.</li>
<li>It&#8217;s Flexible-  You can easily change between such database drivers as PostgreSQL, MySQL or SQLite by pretty much just changing your construct statement.</li>
<li>It&#8217;s Safer &#8211; PDO encourages you to bind parameters to your SQL query&#8217;s, meaning that it&#8217;s significantly less likely your website will suffer from a SQL injection based attack.</li>
</ul>
<p><span id="more-1907"></span></p>
<h3>Connecting to a Database</h3>
<p>Connecting to a database is pretty simple. Here is how to connect to a MySQL Database.</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
// Define the parameters
$host = 'localhost';
$dbname = 'my_database';
$user = 'mysql_username';
$pass = 'mysql_password';

try {
	// Call the PDO class.
	$db= new PDO('mysql:host='.$host.';dbname='.$dbname, $user, $pass);
} catch(PDOException $e) {
	// If something goes wrong, PDO throws an exception with a nice error message.
	echo $e-&gt;getMessage();
}

?&gt;
</pre>
<h3>Doing A Query</h3>
<p>Again, doing a query is just as simple as:</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
$query = $db-&gt;query('SELECT * FROM `users` ORDER BY ID DESC;');
$result = $query-&gt;fetchAll(PDO::FETCH_ASSOC);

// $result will now contain an object of all the rows in the table 'Users'
?&gt;
</pre>
<p>However, if you are using user variables which may cause a SQL Injection you should bind the parameter to the query (see next example).</p>
<h3>Binding a parameter to a query</h3>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
$query = $db-&gt;prepare('SELECT * FROM `users` WHERE `ID` = :ID: AND `email` = :email: ORDER BY ID DESC LIMIT 0,1;');
$query-&gt;execute(array(':ID:' =&gt; '3', ':email:' =&gt; 'me@email.com'));
$result = $query-&gt;fetchAll(PDO::FETCH_ASSOC);
?&gt;
</pre>
<p>If you bind a parameter to a request, it will sterilize the input so that it will not cause a SQL Injection.</p>
<h3>Useful Resources</h3>
<p><a href="http://php.net/manual/en/book.pdo.php">PHP Manual: PHP Data Objects</a></p>
<p><a href="http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/">Nettuts+: Why you Should be using PHP’s PDO for Database Access</a></p>
<p><a href="http://www.amazon.co.uk/gp/product/0596804377/ref=as_li_ss_tl?ie=UTF8&#038;tag=fulondes-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0596804377">PHP: The Good Parts</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=&#038;l=as2&#038;o=2&#038;a=0596804377" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
<h3>Update:</h3>
<p><a href="http://news.php.net/php.internals/53799">As of PHP 5.4 the MySQL extension will be softly deprecated</a>. This means you really should start using PDO ASAP!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1907-pdo-php-data-objects-starter-guide.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP&#8217;s Ctype Functions</title>
		<link>http://www.fullondesign.co.uk/coding/php/1953-phps-ctype-functions.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1953-phps-ctype-functions.htm#comments</comments>
		<pubDate>Sat, 05 Mar 2011 13:00:48 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1953</guid>
		<description><![CDATA[A few days ago I was researching methods of validating alphanumeric strings and I was shown PHPs Ctype Functions by Sebastian Roming. In a nutshell they are a group of PHP functions why can be used to check strings to see if they are alphanumeric, numeric etc without using regex (So they are fast!). The [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I was researching methods of validating alphanumeric strings and I was shown PHPs <a href="http://www.php.net/manual/en/ref.ctype.php">Ctype Functions</a> by <a href="http://www.sebastianroming.de/">Sebastian Roming</a>.</p>
<p>In a nutshell they are a group of PHP functions why can be used to check strings to see if they are alphanumeric, numeric etc without using regex (So they are fast!). The key thing to remember is that they return TRUE or FALSE, unlike filter_var which returns FALSE or the string.<br />
Here is the code example:</p>
<pre class="brush: plain; title: ; notranslate">&lt;?php
// Check if input is alphanumeric (letters and numbers)
ctype_alnum('abcdef1234'); // This returns TRUE
ctype_alnum('£%^&amp;ab2'); // This on the otherhand returns FALSE

// check if input is alpha (letters)
ctype_alpha('dssfsdf'); // returns TRUE
ctype_alpha('12345dssfsdf'); // Returns FALSE

// Check if the input is numeric
ctype_digit('1234'); // TRUE
ctype_digit('1as2d34f'); // FALSE
?&gt;
</pre>
<p><span id="more-1953"></span></p>
<p>It also contains functions to check for just numeric strings, uppercase strings and lowercase strings.</p>
<pre class="brush: plain; title: ; notranslate">&lt;?php
// Uppercase
ctype_upper('HELLO'); // TRUE
ctype_upper('hElLo'); // FALSE

// Lowercase
ctype_lower('hello'); // TRUE
ctype_lower('HeLLo'); // FALSE
?&gt;</pre>
<p>Handy right? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1953-phps-ctype-functions.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to validate an email address with PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/1948-how-to-validate-an-email-address-with-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1948-how-to-validate-an-email-address-with-php.htm#comments</comments>
		<pubDate>Sat, 05 Mar 2011 12:09:12 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1948</guid>
		<description><![CDATA[Validating an email address is a great way to reduce spam on your website, but there are several methods to do it. You could use a messy regex approach or alternatively you could also use PHP built in functions, it&#8217;s really up to you. Here is the function I use: Free feel to copy/share.]]></description>
			<content:encoded><![CDATA[<p>Validating an email address is a great way to reduce spam on your website, but there are several methods to do it. You could use a messy regex approach or alternatively you could also use PHP built in functions, it&#8217;s really up to you. Here is the function I use:</p>
<pre class="brush: plain; title: ; notranslate">&lt;?php
function validEmail($email){
	// Check the formatting is correct
	if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
		return FALSE;
	}

	// Next check the domain is real.
	$domain = explode(&quot;@&quot;, $email, 2);
	return checkdnsrr($domain[1]); // returns TRUE/FALSE;
}

// Example
validEmail('real@hotmail.com'); // Returns TRUE
validEmail('fake@fakedomain.com'); // Returns FALSE
?&gt;</pre>
<p>Free feel to copy/share.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1948-how-to-validate-an-email-address-with-php.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting the Weather in PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/1917-getting-the-weather-in-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1917-getting-the-weather-in-php.htm#comments</comments>
		<pubDate>Sun, 27 Feb 2011 22:43:32 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1917</guid>
		<description><![CDATA[A few months ago I made a small PHP class which can get the weather based on latitude and longitude. Anyway you can now download it and contribute to it over at Google Code. Here is a code example of how to get the weather: Enjoy!]]></description>
			<content:encoded><![CDATA[<p>A few months ago I made a small PHP class which can get the weather based on latitude and longitude. Anyway you can now <a href="http://code.google.com/p/weather-class/">download it and contribute to it</a> over at Google Code.</p>
<p>Here is a code example of how to get the weather:</p>
<pre class="brush: plain; title: ; notranslate">$w = new Weather('50.799995', '-1.065545'); // Input the Latitude and Longitude
echo $w-&gt;getLocation()-&gt;getWeather()-&gt;sayHuman();
// Ouput~: Portsmouth, England, PO4 8 | Partly Cloudy 4°C, Humidity: 93%, Wind: N at 8 mph</pre>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1917-getting-the-weather-in-php.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter OAuth Class 1.0 Released</title>
		<link>http://www.fullondesign.co.uk/coding/php/1773-twitter-oauth-class-1-0-released.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1773-twitter-oauth-class-1-0-released.htm#comments</comments>
		<pubDate>Fri, 05 Nov 2010 16:56:23 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1773</guid>
		<description><![CDATA[A few weeks ago I wrote a neat little PHP Class which makes talking to twitter via their API really easy for Socialize This. You can download it and contribute to it, on it&#8217;s Google Project homepage. Here are a few quick examples of how to use it: Update you Timeline (Send a tweet) Get your [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I wrote a neat little PHP Class which makes talking to twitter via their API really easy for Socialize This. You can download it and contribute to it, on it&#8217;s <a href="http://code.google.com/p/twitter-oauth-class/">Google Project homepage</a>. Here are a few quick examples of how to use it:</p>
<h3>Update you Timeline (Send a tweet)</h3>
<pre class="brush: php; title: ; notranslate">$t-&gt;updateStatus('Messing about with my Twitter API script');</pre>
<h3>Get your Mentions</h3>
<pre class="brush: php; title: ; notranslate">$t-&gt;mentions();</pre>
<h3>Get a users timeline</h3>
<pre class="brush: php; title: ; notranslate">$t-&gt;getTimeline('Rogem002');</pre>
<p>Enjoy <img src='http://www.fullondesign.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1773-twitter-oauth-class-1-0-released.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shorten URLs using the Google URL Shortener and PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/1741-shorten-urls-using-the-google-url-shortener-and-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1741-shorten-urls-using-the-google-url-shortener-and-php.htm#comments</comments>
		<pubDate>Fri, 01 Oct 2010 00:17:30 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[APi]]></category>
		<category><![CDATA[goo.gl]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Google URL Shortener]]></category>
		<category><![CDATA[Url]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1741</guid>
		<description><![CDATA[A few days ago Google opened up their URL shortening service goo.gl to the public. Luckily it is pretty easy to make use of the API and shorten URL&#8217;s in PHP. Here is a function I put together which you can make use of. If you want to read up a bit more about the [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago Google opened up their URL shortening service <a href="http://goo.gl/">goo.gl</a> to the public. Luckily it is pretty easy to make use of the API and shorten URL&#8217;s in PHP. Here is a function I put together which you can make use of.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
// Coded by Mike Rogers (http://www.fullondesign.co.uk/) 1st October 2010.

function shorten($url, $qr=NULL){
	if(function_exists('curl_init')){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_URL, 'http://goo.gl/api/shorten');
		curl_setopt($ch, CURLOPT_POST, TRUE);
		curl_setopt($ch, CURLOPT_POSTFIELDS, 'security_token=null&amp;url='.urlencode($url));

		$results = curl_exec($ch);
		$headerInfo = curl_getinfo($ch);
		curl_close($ch);

		if ($headerInfo['http_code'] === 201){ // HTTP Code 201 = Created
			$results = json_decode($results);
			if(isset($results-&gt;short_url)){
				$qr = !is_null($qr)?'.qr':'';
				return $results-&gt;short_url.$qr;
			}
			return FALSE;
		}
		return FALSE;	

	}
	trigger_error(&quot;cURL required to shorten URLs.&quot;, E_USER_WARNING); // Show the user a neat error.
	return FALSE;
}

// Example: Just the Short URL
echo shorten('http://www.google.com/');

// Example: Give the Short Code URL and image it.
$qrURL = shorten('http://www.google.com/', TRUE);
echo '&lt;img src=&quot;'.$qrURL.'&quot; /&gt;';
?&gt;</pre>
<p>If you want to read up a bit more about the goo.gl shortener, take a look at <a href="http://www.mattcutts.com/blog/goo-gl-url-shortener/">Matt Cutts post on his blog</a>.</p>
<p><em>Edit &#8211; Added QR Support.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1741-shorten-urls-using-the-google-url-shortener-and-php.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>Rogem</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; title: ; notranslate">&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>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>Rogem</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.]]></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; title: ; notranslate">
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>
		<item>
		<title>PHP Function: realpath()</title>
		<link>http://www.fullondesign.co.uk/coding/php/1297-php-function-realpath.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1297-php-function-realpath.htm#comments</comments>
		<pubDate>Sat, 19 Dec 2009 23:23:49 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Absolute Link]]></category>
		<category><![CDATA[Php Functions]]></category>
		<category><![CDATA[realpath]]></category>
		<category><![CDATA[Symbolic Link]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1297</guid>
		<description><![CDATA[One functions I wish I had known about when i start learned PHP is the realpath() function. Pretty much what it does is take symbolic link (such as &#8216;../&#8217; or &#8216;/&#8217;) and returns a canonicalized absolute link (like &#8216;/home/public_html/folder&#8217;). Here is an example of it in action:]]></description>
			<content:encoded><![CDATA[<p>One functions I wish I had known about when i start learned PHP is the <a href="http://uk2.php.net/manual/en/function.realpath.php">realpath()</a> function. Pretty much what it does is take symbolic link (such as &#8216;../&#8217; or &#8216;/&#8217;) and returns a canonicalized absolute link (like &#8216;/home/public_html/folder&#8217;). Here is an example of it in action:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
echo realpath('../');
// Would return: /home/mike/www/blogposts
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1297-php-function-realpath.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checking for embarrassing words in a string</title>
		<link>http://www.fullondesign.co.uk/coding/php/1069-checking-for-embarrassing-words-in-a-string.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/1069-checking-for-embarrassing-words-in-a-string.htm#comments</comments>
		<pubDate>Tue, 16 Jun 2009 20:28:29 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[embarrassing words]]></category>
		<category><![CDATA[silly]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=1069</guid>
		<description><![CDATA[I was recently on YouTube and I noticed that did not check the shortened strings for potentially embarrassing shortenings of words. How to make a great example? Here is the code so you can shorten strings and check for potentially embrassing words.]]></description>
			<content:encoded><![CDATA[<p>I was recently on YouTube and I noticed that did not check the shortened strings for potentially embarrassing shortenings of words.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1070" title="YouTube's Cock Up" src="http://www.fullondesign.co.uk/wp-content/uploads/2009/06/youtube-cock-up_small.png" alt="YouTube's Cock Up" width="439" height="263" /><em>How to make a great example?</em></p>
<p>Here is the code so you can shorten strings and check for potentially embrassing words.</p>
<p><span id="more-1069"></span></p>
<pre class="brush: php; title: ; notranslate">&lt;?php
// String Cleaner - Cleans words you don't want out of strings.

// Step 1 - Define the string and the words yoiu want to remove.
$string = 'this is my silly input how cool is it?';
$words_to_remove ='silly|my|eggs'; // Seperate words with | this is regular expression.

// Step 2 - shorten the string
$string = substr($string, 0, 23); // This with return the first 23 characters (including spaces) in the string.

// Step 3 - Remove the words
echo preg_replace('#\b('.$words_to_remove.')\b#is', '', $string); // This will remove the 

// This would return:
// this is input
?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/1069-checking-for-embarrassing-words-in-a-string.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic
Database Caching 1/42 queries in 0.019 seconds using disk: basic
Object Caching 570/660 objects using disk: basic

Served from: www.fullondesign.co.uk @ 2012-02-04 09:04:00 -->
