Category Archives: PHP/MySQL

Useful Regular Expressions

1. Matching an URL There are many regular expressions out there that match an URL, but this is the best I’ve found so far: ‘#((https?://|www\.)([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)#‘ 2. Match email “/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i”

Posted in PHP/MySQL | Leave a comment

PHP extract the first x characters of a text

This function extracts the first x characters of a given text, which we get from a database. This is usually performed on posts on a blog, where you don’t want to display the whole post in the homepage, but just let’s say 500 characters of the post. Ok here is the function: function extract($post_id, $length) […]

Posted in PHP/MySQL | 1 Comment

Top 5 PHP functions you cannot live without

1. include() 2. isset() 3. mysql_query() 4. mysql_fetch_array() 5. substr()

Posted in PHP/MySQL | 1 Comment

Happy Birthday PHP

On 8 June 2010 PHP became 15 years old, keep on going PHP.

Posted in PHP/MySQL | Leave a comment

What are Design Patterns?

“Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice” by Christopher Alexander, architect (the guy in the […]

Also posted in Design Patterns | 4 Comments

Cookies VS Sessions

The main difference between cookies and sessions is that cookies are stored in the user’s browser, and sessions are not. This difference determines what each is best used for. A cookie can keep information in the user’s browser until deleted. If a person has a login and password, this can be set as a cookie […]

Posted in PHP/MySQL | Leave a comment

Selling PHP to your boss

If you want to use PHP in your company and your manager favours another solution, or if you are trying to convince a potential client that PHP really is a superior choice for the web, you’re going to need to have a clear-cut set of reasons why you believe PHP is the superior language. This […]

Posted in PHP/MySQL | 4 Comments