I often find myself doing quick checks like this:
if (!eregi(\'.php\', $fileName)) {
$filename .= \'.php\';
}
But as eregi() was deprec
stristr achieves exactly the same result as eregi (at least when you don't use regular expressions):
if (!stristr($fileName, '.php'))
$filename.='.php';
You could also make a "fake" eregi this way:
if (!function_exists('eregi')) {
function eregi($find, $str) {
return stristr($str, $find);
}
}
Update: Note that stristr
doesn't accept regular expressions as eregi
does, and for this specific case (checking the extension), you'd better go with vartec's solution.