How To Generate tinyURLs in PHP

All you need is allow_url_fopen enabled in your php.ini and PHP version 4.3.0 or higher. If you don't know whether you have allow_url_fopen enabled, just run the function phpinfo(), which displays all of your PHP settings.

$shortenedurl = file_get_contents('' . urlencode('http://' . $_SERVER['HTTP_HOST']  . '/' . $_SERVER['REQUEST_URI']));

This line of code send a request to with necessary parameters and you will get a url of the current page returned.