首页  >  文章  >  后端开发  >  Call to undefined function preg_filter()

Call to undefined function preg_filter()

WBOY
WBOY原创
2016-06-06 20:33:28915浏览

用了preg_filter()函数,老提示Call to undefined function preg_filter() ,怎么回事啊?

回复内容:

用了preg_filter()函数,老提示Call to undefined function preg_filter() ,怎么回事啊?

<code>php</code><code>//php 5.3-
if (!function_exists('preg_filter')) {

    function preg_filter($pattern, $replace, $subject, $limit = -1 , &$count = null) {

      if(!is_array($subject)) {
        $noArray = 1 ;
        $subject = array($subject);
      }

      $preg = preg_replace($pattern, $replace, $subject, $limit,  &$count);

      $diff = array_diff($preg, $subject);

      if($noArray == 1) $diff = implode($diff) ;

      return $diff ;

    }

  }


</code>

看下是不是PHP版本问题,这个函数应该是 5.3+之后的

preg_filter
(PHP 5 >= 5.3.0)
preg_filter — Perform a regular expression search and replace

可以用了,但前提必须是php5.3或以上的,都怪自己在编辑器里面没配置好才会出现这个错误的,I'm sorry~

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn