Home \ PHP
Quick Tip: “e” Modifier For Regular Expression
There’s a question about regular expression on WPQuestions yesterday that received some interesting solutions. The question is replace all semicolons between [[ and ]]. I myself found a solution uses “e” modifier which I think interesting.
PHP Quick Tip: Comment Block
PHP has 2 types of comments: comment block (for long comments in many continuous lines) and short comment (for one line). When test code, if we don’t want to a block of code execute, we can disable it by turning them into comment blocks using /* ... */, and when we want to execute it,...
Create A Multiple URL Shortener Page
There are various url shortener services on the Internet, you can use free services such as bit.ly, tinyURL or create your own url shortener using some open sources. In this article, I’ll show you how to create a simple page that shows short urls created by multiple url shortener services. I’ll use HTML5, CSS3 for...
URL Shortener: Principles, Sample Code And Sources
URL Shortener makes a short version of a long given URL. There are many URL shorteners out there like bit.ly, tinyurl or is.gd. Of course we can use their API to create short urls, but it’s not interesting for developers, who want to look into the very deep of the mechanism. Short url often has...
How To Create A Better Meta Box In WordPress (Part 2)
After I wrote the article How To Create A Better Meta Box In WordPress Post Editing Page, I received some questions that asked me how to create multiple meta boxes for multiple post types (in WordPress 3.0). So I decide to improve the script to do that.
Easily Expand Short URL Using PHP
Short url services like bit.ly, tinyurl are very helpful to make a short version of our long urls. In some cases, we want to expand short url to make sure it has been shortened correctly, or to check if someone gives us a harmful link. Expanding short url to long url using PHP is easy...
Avoid Duplication In WordPress Theme Code
When coding a WordPress theme, you might meet the situation when a section of code is duplicated across pages, for example the Loop is presented in all Index, Archive and Category pages. To avoid such code duplication, we can load a template part into a template file (other than header, sidebar, footer) to make it...
