Might I be picky and state that the should be a +, as the will allow an empty string to validate? Furthermore, you do not have to escape the . in the character class. Lastly, you have a . rather than a ; at the end of the echo line... 😉
You could also shorten it a bit by using the i flag, to denote case insensativity.
if (preg_match('/^[a-z0-9.]+$/i', $foo)) {
echo "string validates";
}