一、使用Load
1、在extend文件夾下面放extend/mail/phpmailer.php文件;
2、在applicatioon/index.php文件中寫入
define('EXTEND_PATH', '../extend/');
3、在index控制器中引用
use think\Loader; Loader::import('mail\PHPMailer', EXTEND_PATH); $mail=new PHPMailer();
二、使用use
1、在extend文件夾下面放extend/mail/phpmailer.php文件;
2、打開phpmailer.php文件,並在頭部添加
namespace mail;
3、在index控制器中引用
use mail;//此步驟相當於引入了所有命名空間為mail的文件 $mail=new \mail\PHPMailer();//PHPMailer is a name of class;
