Form validation is an essential process for maintaining data integrity, enhancing the user experience, and ensuring security of your website or service. The importance of form validation cannot be overstated. It plays a vital role in protecting both the user and the system from potential harm. For users, it ensures that their input is acknowledged and processed correctly, reducing frustration and improving…
The preg_replace_callback() function in PHP is one of the many regular expression functions available in the language, and can be incredibly powerful as they offer far more versatility when replacing matched text. I recently wanted to use it to implement a very basic templating class.
This function goes beyond the preg_replace() function which is just a standard regular expression find/replace.…
Randall Munroe of XKCD explains wonderfully how through 20 years of effort, we've successfully trained everyone to use passwords that are hard for humans to remember, but easy for computers to guess. As humans, we see a password that seems entirely nonsensical and assume it to be as difficult to crack as it is to remember. Despite this logical fallacy, developers worldwide still insist on enforcing…
I often quote Jamie Zawinski for his brilliant line on usage of regular expressions:
Some people, when confronted with a problem, think
“I know, I'll use regular expressions.” Now they have two problems.
Despite this, I still use them to within an inch of their life because, when used correctly, they are incredibly useful; across everything from find/replace in a document or IDE, form…