How to implement automatic loading of class maps in Yii_PHP tutorial

WBOY
Release: 2016-07-13 09:58:28
Original
811 people have browsed it

Yii's method of automatically loading class maps

This article describes the example of Yii's method of automatically loading class maps. Share it with everyone for your reference. The details are as follows:

$classMap, a static attribute inherited by Yii, can be used for Yii's automatic loading of class maps. The key in the array is the class name, and the value in the array is the path to the corresponding class file.

1

2

3

4

5

6

7

8

9

require_once($yii);

$app = Yii::createWebApplication($config);

Yii::$classMap = array(

'JPhpMailer' => Yii::getPathOfAlias('ext') .

'/phpmailer/JPhpMailer.php',

);

$app->run();

// 使用的时候可以不用再通过Yii::import()去引入文件。

$mailer = new JPhpMailer();

1 2 3

4

6 7 8 9
require_once($yii); $app = Yii::createWebApplication($config);
Yii::$classMap = array(
'JPhpMailer' => Yii::getPathOfAlias('ext') . '/phpmailer/JPhpMailer.php', ); $app->run(); // You don’t need to import files through Yii::import() when using it. $mailer = new JPhpMailer();
http://www.bkjia.com/PHPjc/977618.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/977618.htmlTechArticleYii's method of automatically loading class maps. This article describes the method of Yii's method of automatically loading class maps. Share it with everyone for your reference. The details are as follows: A static property inherited by Yii...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!