thinkphp5使用load和use引入第三方类

一、使用Load

1、在extend文件夹下面放extend/mail/phpmailer.php文件;

2、在applicatioon/index.php文件中写入

define('EXTEND_PATH', '../extend/');

3、在index控制器中引用

use thinkLoader;
Loader::import('mailPHPMailer', EXTEND_PATH);
$mail=new PHPMailer();

二、使用use

1、在extend文件夹下面放extend/mail/phpmailer.php文件;

2、打开phpmailer.php文件,并在头部添加

namespace mail;

3、在index控制器中引用

use mail;//此步骤相当于引入了所有命名空间为mail的文件

$mail=new mailPHPMailer();//PHPMailer is a name of class;
原文地址:https://www.cnblogs.com/leilei-1/p/8007093.html