thinkphp3.2 Introduction of PHP instantiation classes

Source: Internet
Author: User
If your class library does not take a namespace, you need to use the Import method to load the class library file before instantiating it, for example: we have defined a Counter class (located at com/sina/util/counter.class.php):

  1. Class Counter {
  2. }

When used, it needs to be called as follows:

  1. Import (' Com.Sina.Util.Couter ');
  2. $object = new \counter ();

Above is an example given by thinkphp.

I was directly involved in the actual time it was supposed to be.

Require (app_path. ' admin/controller/disqus-api/wp-api.php ');//Import Disqusapi class, this class copied from WordPress wp_api.php
Require (app_path. ' admin/controller/disqus-api/category.php ');

The above is used in the WordPress Disqus API folder within the two API class files

Before 3.2 I was directly new to the class name contained in the OK,

After 3.2, we'll

$DSQ _class=new \disquswordpressapi ($message [' short_name '], $api _key, $dsq _user_api_key);

So to instantiate

Make a note 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.