Good alternative to eregi() in PHP

前端 未结 8 1579
感情败类
感情败类 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 09:10

    if (! stristr($fileName, '.php')) $filename.='.php';

    moff's answser had the parameters backwards.

    http://php.net/manual/en/function.stristr.php

    0 讨论(0)
  • 2021-01-04 09:16

    If you go for the "fake" eregi, you shold trigger a notice inside the fake function: trigger_error('Some code still use eregi',E_USER_NOTICE); This way you will easily catch the forgotten eregi calls and can replace them.

    0 讨论(0)
提交回复
热议问题