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”
Category Archives: PHP/MySQL
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) [...]
Top 5 PHP functions you cannot live without
1. include() 2. isset() 3. mysql_query() 4. mysql_fetch_array() 5. substr()
Happy Birthday PHP
On 8 June 2010 PHP became 15 years old, keep on going PHP.
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 [...]
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 [...]
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 [...]