PHP Code to Get Current Page’s URL

Post Thumbnail of PHP Code to Get Current Page's URL

It is quite often that we need to redirect users back to current URL. I wrote my own function for this purpose, but then I realized some weaknesses: it cannot capture HTTPS and the port number, which is very important for some websites.

Filed in Web Development
Posted on 1 July 2012 • 1 comment

Reducing Image File Size (Compression) using PHP GD

Post Thumbnail of Reducing Image File Size (Compression) using PHP GD

Most of the time, photos uploaded by users are not optimized for web. In other words, they might not be using the best file format for their photos, thus taking much more spaces in your server than it actually need. Using PHP, you can easily reduce the file size of those uploaded images during upload time. But of course, when reducing the file size, we sacrifice the image quality. Therefore, if you are running image uploader website, this is not recommended.

Filed in Web Development
Posted on 16 February 2012 • 6 comments

PHP – Using oEmbed API to Embed Videos

Post Thumbnail of PHP - Using oEmbed API to Embed Videos

oEmbed is a format for allowing an embedded representation of a URL on third party sites. Which means, if we have a video page’s URL, we can easily get the video thumbnail photo, video title, HTML code to embed it in our website and more. But of course, the video site must have oEmbed support in order for us to do that.

Filed in Web Development
Posted on 30 January 2012 • 0 comment

PHP MySQL – Get Next Auto Increment Value of a Table

Post Thumbnail of PHP MySQL - Get Next Auto Increment Value of a Table

We do not often need this but sometimes when we need to retrieve the next auto increment value of a table (without incrementing the auto increment value of course), this solution below will help.

Filed in Web Development
Posted on 14 January 2012 • 1 comment

PHP Smart Date Function – Display Time Elapsed (Difference) Based on a Given Timestamp

Post Thumbnail of PHP Smart Date Function - Display Time Elapsed (Difference) Based on a Given Timestamp

As a web developer, we often need to display dates in our website. As a web user myself, I don’t like to read full dates like “26 November 2011 11:30PM” because it takes me a little while to interpret the date. I prefer reading smart dates like “1 hour ago” or “6 months ago”. Therefore, here I wrote a quick and simple function in PHP that display the time difference/elapsed based on a given timestamp value.

Filed in Web Development
Posted on 12 December 2011 • 0 comment

URL Canonicalization (Canonization) Using PHP

Post Thumbnail of URL Canonicalization (Canonization) Using PHP

When your website can be accessed via several URLs, such as http://www.example.com & http://example.com, you might want to decide a best URL and use only that URL whenever you link back to your site, because this helps your site in terms of SEO.

Filed in SEO, Web Development
Posted on 13 February 2011 • 0 comment

PHP Function to Auto Convert URL into Clickable Hyperlink (Anchor <a> Tag)

Post Thumbnail of PHP Function to Auto Convert URL into Clickable Hyperlink (Anchor &lt;a&gt; Tag)

In wordpress, if you want to auto convert all URLs in your string into clickable hyperlinks, you can actually do it using the built-in function make_clickable(). If you need to do that outside of wordpress, you can refer to the function’s source code at..

Filed in Web Development
Posted on 2 September 2009 • 19 comments