Name

registerFilter() - 注册过滤器

说明

void registerFilter(string type,
mixed callback);

注册过滤器。 参数如下:

  • type defines the type of the filter. Valid values are "pre", "post", "output" and "variable".

  • callback defines the PHP callback. it can be either:

    • A string containing the function name

    • An array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string containing the method-name

    • An array of the form array($class, $method) with $class being the class name and $method being a method of the class.

Technical Note

If the chosen function callback is of the form array(&$object, $method), only one instance of the same class and with the same $method can be registered. The latest registered function callback will be used in such a scenario.

prefilter前置过滤器,在模板编译之前执行的过滤器。 详情参见前置过滤器

postfilter后置过滤器,在模板编译成PHP后执行的过滤器。 详情参见后置过滤器

outputfilter输出过滤器,在模板将要displayed前执行的过滤器。 详情参见输出过滤器

参见 unregisterFilter(), loadFilter(), $autoload_filters, 前置过滤器 后置过滤器 输出过滤器