【23】用户自定义扩展功能实现
上一个教程中,我们已经实现了公共配置项的实现,这一节中我们来实现用户自定义扩展功能。我们都知道,尽管框架中已经定义许多函数和各种类,但有时候它并不能完全满足我们的需求,所以我们需要引入自己定义的类和函数。
1、在框架配置文件config.php中加入配置
//载入Common/Lib目录下的文件,可以载入多个
'AUTO_LOAD_FILE'=><span style="color: #0000ff">array</span>(),
2、在Application类文件中定义一个私有的静态方法,用来C函数读取用户自定义的配置文件,并循环载入,如下:
private static function _import_user_file(){ $fileArr=C('AUTO_LOAD_FILE'); if(is_array($fileArr) || !empty($fileArr)){ foreach ($fileArr as $v) { require_once COMMON_LIB_PATH.'/'.$v; } } }
3、Application类文件的run方法进行调用
//载入用户自定义的文件
self::_import_user_file();
4、用户编写自定义函数或类放在根目录下的Common/Lib目录下面,如function1.php、People.class.php
5、在公共配置文件Common/Config/config.php中配置用户自定义文件
'AUTO_LOAD_FILE'=><span style="color: #0000ff">array</span>('function1.php','People.class.php'),
6、在控制器中调用函数方法或者实例化类
<span style="color: #008000">//</span><span style="color: #008000">类</span> <span style="color: #800080">$peopleobj</span>=<span style="color: #0000ff">new</span><span style="color: #000000"> People(); </span><span style="color: #800080">$peopleobj</span>-><span style="color: #000000">run(); </span><span style="color: #008000">//</span><span style="color: #008000">函数</span> p(<span style="color: #800080">$_SERVER</span>);
到这里,用户自定义扩展功能就实现了,感谢后盾网马老师的教程...

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)