Thinkphp3.2 introduce php instantiation class-php Tutorial

Source: Internet
Author: User
Thinkphp3.2 introduces the php instantiation class. if your class library does not use a namespace, you need to use the import method to load the class library file before instantiating It. for example: we define a Counter class (located in Com/Sina/Util/Counter. class. php ):

  1. Class Counter {
  2. }

When using this function, you need to call it as follows:

  1. Import ('com. Sina. Util. Couter ');
  2. $ Object = new \ Counter ();

The preceding example is provided by thinkphp.

In actual use, I directly include

Require (APP_PATH. 'admin/Controller/disqus-api/wp-api.php '); // import the disqusApi class, which is copied from wordpress wp_api.php
Require (APP_PATH. 'admin/Controller/disqus-api/category. php ');

The above uses two api files in the disqus api folder in wordpress

Before 3.2, I directly added the class name included in "new,

After 3.2

$ Dsq_class = new \ DisqusWordPressAPI ($ message ['short _ name'], $ api_key, $ dsq_user_api_key );

In this way, instantiate

Make a record of the above content

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.