Good alternative to eregi() in PHP

前端 未结 8 1584
感情败类
感情败类 2021-01-04 08:39

I often find myself doing quick checks like this:

if (!eregi(\'.php\', $fileName)) {
    $filename .= \'.php\';
}

But as eregi() was deprec

8条回答
  •  情话喂你
    2021-01-04 08:55

    I generally create and endsWith function; or other simple string manipulation functions for this kind of stuff.

    function endsWith($string, $end){
        return substr($string, -strlen($end)) == $end;
    }
    

提交回复
热议问题