Tag: php 5
-
Validating An Email Address in PHP 5
In PHP 5.2 Zend has added a function called filter_var(). It validates a lot of things for you without having to write any regular expressions or anything else. You do it like this: if (filter_var($emailAddress, FILTER_VALIDATE_EMAIL) !== false) { print ‘valid email’; } else { print ‘Invalid email’; } filter_var()returns the value back if its…
-
Design Patterns – Singletons in PHP 5.x
Design Patterns (and anti-patterns) are techniques of programming. There are a lot of design patterns. It is upto the programmer to pick and choose which patterns to use based on their needs. Singleton is also a design pattern. A singleton is a type of class which can have only 1 object of its kind through…