Home > Backend Development > PHP Tutorial > Yii implements the method of automatically loading class maps, yii implements loading maps_PHP tutorial

Yii implements the method of automatically loading class maps, yii implements loading maps_PHP tutorial

WBOY
Release: 2016-07-13 09:58:35
Original
948 people have browsed it

Yii implements the method of automatically loading class maps, yii implements loading 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.

require_once($yii);
$app = Yii::createWebApplication($config);
Yii::$classMap = array(
  'JPhpMailer' => Yii::getPathOfAlias('ext') . 
  '/phpmailer/JPhpMailer.php',
);
$app->run();
// 使用的时候可以不用再通过Yii::import()去引入文件。
$mailer = new JPhpMailer();
Copy after login

I hope this article will be helpful to everyone’s PHP programming based on the Yii framework.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/977788.htmlTechArticleYii implements the method of automatically loading class maps, yii implements loading maps. This article describes how Yii implements automatic loading of class maps. method. Share it with everyone for your reference. The details are as follows: Yii follows...
Related labels:
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