Introduction

Learn about regular expressions in PHP.

We'll cover the following...

We often use HTML forms to collect data or inputs from users. Our role as developers is to make sure that the submitted data is valid. Imagine a form where users are allowed to submit a name in the email field. With such a form, we wouldn’t be able to contact the user.

Should we trust the user and assume that they’ll never make a mistake in our forms? forms? Because humans are fallible, the wise approach would be to not work with that assumption.

As the adage says:

“Never ever trust user inputs.”

We must always check whether the submitted data meets our expectations.

The goal of this section is to explore the different techniques for validating form inputs. More precisely, we’ll be learning about:

  • Regular expressions, also known as Regex.
...