ThinkPHP introduces classes in detail, thinkphp introduces in detail
This example describes how thinkPHP introduces classes. We will share this with you for your reference. The details are as follows:
Phpmailer is used as an example.
1. Put the core file in the ORG directory
2. Introduce this class file in use
How to introduce it?
import('@.ORG.phpmailer');
This indicates introducing the phpmailer. class. php file in ORG of the current project.
3. You can use the class in the file after the introduction.
Public function sendEmail () {import ('@. ORG. phpmailer '); $ mail = new PHPMailer (); // create a mail sending class, the class name is not necessarily the same as the introduced file name $ mail-> CharSet = "UTF-8 "; $ address = "jiqing9006@qq.com"; $ mail-> IsSMTP (); // use SMTP to send $ mail-> Host = "smtp.126.com "; // your enterprise Post Office domain name $ mail-> SMTPAuth = true; // enable SMTP verification function $ mail-> Username = "jiqing9006@126.com "; // Post Office username (enter the complete email Address) $ mail-> Password = "XXXXXXXX"; // post office Password $ mail-> Port = 25; $ mail-> F Rom = "jiqing9006@126.com"; // email address of the sender $ mail-> FromName = "Ji Qing"; $ mail-> AddAddress ("$ address ", "Ji Qing"); // recipient address, which can be replaced with any email address to receive emails. The format is AddAddress ("recipient email", "Recipient Name ") // $ mail-> AddReplyTo ("", ""); // $ mail-> AddAttachment ("/var/tmp/file.tar.gz "); // Add an attachment $ mail-> IsHTML (true); // set email format to HTML // use HTML format $ mail-> Subject = "hello "; // email title $ mail-> Body = "Hello, welcome to join us! "; // Email content. if HTML is set above, it can be HTML if (! $ Mail-> Send () {echo "email sending failed. <p>"; echo "error cause:". $ mail-> ErrorInfo; exit ;}}