This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Examples of annoying code */ | |
if ( $coder === 'Silly' ) bang_head(); | |
while ( $coder === 'Silly' ) | |
bang_head(); | |
endwhile; | |
/* Examples of good code*/ | |
if ( $coder !== 'Silly' ){ Drink_Beer(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!–[if IE]> | |
This will only show for Internet Explorer (IE) | |
<![endif]–> | |
<!–[if !IE]> | |
This will only show if the client is not using IE. | |
<!–[endif]> | |
<![if IE 6]–> | |
Only shows on IE6 | |
<!–[endif]> | |
<![if lte IE 6]–> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # File created on 3rd April 2009 by Mike Rogers (http://www.fullondesign.co.uk/). | |
/* | |
function – recent_stumbles(string $username [, string $type= NULL [, int $limit = 5]]) | |
$username – The stumbleupon username, such as rogem002 | |
$type – Default: NULL – What you want to limit your rss to show. Can be NULL, blog, comments, favorites or reviews | |
$limit – Default: 5 – how many tweets you wish to show, must be numeric. | |
*/ | |
function recent_stumbles($username, $type=NULL, $limit=5){ | |
if(!is_numeric($limit)){$limit = 5;} | |
if($type !== NULL && $type !== 'blog' && $type !== 'comments' && $type !== 'favorites' && $type !== 'reviews'){$type = NULL;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # File created on 1st April 2009 by Mike Rogers (http://www.fullondesign.co.uk/). | |
/* | |
function – recent_tweets(string $username [, int $limit = 5]) | |
$username – Your twitter username, such as rogem002 | |
$limit – Default: 5 – how many tweets you wish to show, must be numeric. | |
*/ | |
function recent_tweets($username, $limit=5){ | |
if(!is_numeric($limit)){$limit = 5;} | |
$xml = simplexml_load_file('http://search.twitter.com/search.atom?q=from%3A'.urlencode($username)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$salt = '%$£Salt_Here*(&^'; | |
$password = md5('password'.$salt); | |
// $password will now return 5747563a265df7a3250884394c0a05e0 | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Filter an Email Address | |
var_dump(filter_var('email@example.com', FILTER_VALIDATE_EMAIL)); // Returns: string(17) "email@example.com" | |
// 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@example.com', FILTER_SANITIZE_EMAIL )); // Returns: string(17) "email@example.com" | |
// Filter a URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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&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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo realpath('../'); | |
// Would return: /home/mike/www/blogposts | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<meta http-equiv="X-UA-Compatible" content="chrome=1"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
errors class – Helps management of errors in a script. | |
@version | |
1.0 | |
@author | |
Mike Rogers (FullOnDesin.co.uk) | |
@last updated | |
03 June 2009 |