ThinkPHP introduces classes in detail, thinkphp introduces in detail

Source: Internet
Author: User

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 ;}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.