$name = "joe";
if (preg_match('/^[a-zA-Z]+$/', $name) {
}
Chances are, you probably want use this instead:
if (preg_match('/\A[a-zA-Z]+\z/', $name) {
}
Why?
Use of ^ is OK, but $ matches line break characters.
So,
$name = "joe¥n";
if (preg_match('/^[a-zA-Z]+$/', $name) {
echo "match!";
}
Will display "match!" - which is probably something you don't want.