The popular URL shortening service TinyURL provides a quick API that creates TinyURL's on the fly. Here's how you can access that API.

<?php
function createTinyUrl($strURL) {
    $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=" . $strURL);
    return $tinyurl;
}
?>

Make a call to our function above, and it outputs a new tinyURL.

<?php echo(createTinyUrl('http://www.richardcastera.com/2009/05/09/creating-a-tinyurl-with-tinyurl-api/')); ?>