Include HTMLpurifier with Zend_Loader

前端 未结 4 2103
醉梦人生
醉梦人生 2021-02-06 17:58

I want to use the HTMLpurifier in combination with the Zend Framework. I would love to load the Class and its files with the Zend_Loader. How would you include it? Would you jus

4条回答
  •  灰色年华
    2021-02-06 18:44

    you can register an autoloader class using the Zend_Loader class. when you call the registerAutoLoad() method without any parameters, you are actually registering Zend_Loader itself as an autoloader. so:

    Zend_Loader::registerAutoLoad();
    

    // equals to: Zend_Loader::registerAutoLoad('Zend_Loader'),true);

    Zend_Loader tries to load classes using Zend Framework's naming convention, which is like this:

    • each class is defined in a separate file
    • each class name begins with a capitalized letter
    • underlines in class name, means a directory level.

    so if 'Zend_Loader' is the name of a class, it is defined in the file 'Loader.php' in 'Zend' directory in your path. to you PHP can file load this class from file Zend/Loader.php

    if your classes follow this naming convention, they can be automatically loaded using the same autoloader. else, you need to define your own autoloader. write an autoloader class winch can extend Zend_Loader, and define the loading functionality so that it will load classes with other naming conventions. then register your own autoloader with Zend_Loader. like this:

    Zend_Loader::registerAutoLoad('myLoader',true);
    

提交回复
热议问题