Php 如何调用与preg_replace_回调相同的类中的函数?
我有一个功能如下:Php 如何调用与preg_replace_回调相同的类中的函数?,php,Php,我有一个功能如下: function make_clickable($ret) { $ret = ' ' . $ret; // in testing, using arrays here was found to be faster $save = @ini_set('pcre.recursion_limit', 10000); $retval = preg_replace_callback('#(?<!=[
function make_clickable($ret) {
$ret = ' ' . $ret;
// in testing, using arrays here was found to be faster
$save = @ini_set('pcre.recursion_limit', 10000);
$retval = preg_replace_callback('#(?<!=[\'"])(?<=[*\')+.,;:!&$\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#%~/?@\[\]-]{1,2000}|[\'*(+.,;:!=&$](?![\b\)]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret);
if (null !== $retval )
$ret = $retval;
@ini_set('pcre.recursion_limit', $save);
$ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
$ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
// this one is not in an array because we need it to run last, for cleanup of accidental links within links
$ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
$ret = trim($ret);
return $ret;
}
功能使可点击($ret){
$ret=''.$ret;
//在测试中,发现在这里使用阵列更快
$save=@ini\u set('pcre.recursion\u limit',10000);
$retval=preg_replace_回调('#)(?尝试将此函数名作为函数名:
array($this, "_mke_web_ftp_clickable_cb")
感谢Fender,你的解决方案对我来说很有意义,但似乎仍然不起作用。
array($this, "_mke_web_ftp_clickable_cb")