发布于 2016-01-17 09:50:22 | 393 次阅读 | 评论: 0 | 来源: PHPERZ

回调函数

// 写一个接受一个元素参数$element的函数
function my_callback($element) {
        // 隐藏所有的 b 标签
        if ($element->tag=='b')
                $element->outertext = '';
}

// 注册自己的回调函数,参数是函数名称字符串
$html->set_callback('my_callback');

// 回调函数会在打印对象的时候被调用
echo $html; 
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务