PHP

Create Tiny URL Link With PHP Function

Tiny URL site allows you to compress the size of your URLs which is mostly used on the social networking site twitter, because of the limited characters you can use.

But to use the tiny URL feature you have to go there website and fill out a form to get your tiny URL.

With this function you can return the output of the tiny URL to be used anywhere on your site quickly and easily.

function getTinyUrl($url) {
    return file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
}
Back to top

Learn how to code with Treehouse

  • Learn projects with access to 1000+ videos
  • Practice live with our Code Challenge Engine
  • Get help in our members-only forums

Start with a 7 day free trial

Comments

  1. magma-pc.com says:

    I'm not sure exactly why but this web site is loading incredibly slow for me.
    Is anyone else having this issue or is it a problem on my end?
    I'll check back later on and see if the problem still exists.

    1. Paul says:

      Hi just ran a speed test and seems to be running as normal. http://tools.pingdom.com/fpt/#!/PSCrj/https://paulund.co.uk

      Let me know if you spot this again.

      Thanks
      Paul