Fatal error: Call to undefined function: stripos()

为什么会有这样的错误 “Fatal error: Call to undefined function: stripos()”?

查看了下手册:

stripos
(PHP 5)
stripos — Find position of first occurrence of a case-insensitive string
原来他是个PHP5作用的函数,但是网路上还是有很多服务空间是用的 php 4.3, 那么可以用下面的方法解决这个问题:

if(!function_exists('stripos')) {
 function stripos($haystack, $needle, $offset = 0) {
  return strpos(strtolower($haystack), strtolower($needle), $offset);
 }
}

Comments are closed.