Posts in:
validation

Validate terminal command in PHP

Testing if a function exists in PHP is easy. Testing if a command exists on the system is also easy. I’ve never really run into the problem of having to create a compatibility suite script to make sure my PHP script will run without trouble. Simple things like checking the version of PHP installed or the [...]

Validate a Credit Card Number

This code snippet is a regular expression which checks or validates a credit card number.
The Expression: ^([0-9]{4})[\-|\s]*([0-9]{4})[\-|\s]*([0-9]{4})[\-|\s]*([0-9]{2,4})$

Validate a Phone Number

This code snippet is a regular expression which checks or validates a phone number.
The Expression: ^[\+]?([0-9]?)[\(|\s|\-|\.]?([0-9]{3})[\)|\s|\-|\.]*([0-9]{3})[\s|\-|\.]*([0-9]{4})$