Shorten a URL

This example shows how to use tinyurl’s api to genearte a short url from a url you pass, there are other services which offer this functionality

<?php
/**
 * Use tinyurl to generate a short url
 *
 * @param string $url The url that you want to shorten
 */
function ShortUrl($url)

$tinyurl = file_get_contents(“http://tinyurl.com/api-create.php?url=”.$url);
return $tinyurl;
}
//usage example
echo ShortUrl(“http://www.getphp.net/a-google-pagerank-script/“);
?>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*