I often find myself doing quick checks like this:
if (!eregi('.php', $fileName)) {
$filename .= '.php';
}
But as eregi() was deprecated in PHP 5.3 the code now throws errors.
Is there another function that behaves exactly the same way as eregi()? I don’t know anything about regexps and don’t want to learn, so preg_match() etc won’t work for me.
stristr achieves exactly the same result as eregi (at least when you don’t use regular expressions):
You could also make a “fake” eregi this way:
Update: Note that
stristrdoesn’t accept regular expressions aseregidoes, and for this specific case (checking the extension), you’d better go with vartec’s solution.