PHP Knowledge Point 2

Source: Internet
Author: User

When to use an interface or abstract class:
1, if you want to create a model, this model will be used by some closely related objects to use the abstract class. Interfaces are used if you want to create features that will be used by unrelated objects.
2, if the behavior must be inherited from multiple sources, using an interface, the PHP class can inherit multiple interfaces, but cannot extend multiple abstract classes
3, if you know that all classes share a common behavior implementation, use an abstract class and implement that behavior in it. Unable to implement behavior in interface

Namespaces: As the class library expands, it is possible to encounter a situation where two class libraries use the same class name. Because each class is required to have a unique name, it is not possible to use two classes of the same name in the same PHP script

PHP Export Excel:
Header ("Content-type:application/vnd.ms-excel");

Header ("Content-disposition:attachment;filename=downdata.xls");

Header ("Pragma:no-cache");

Header ("expires:0");

echo "aa/t/n";

echo "bb/t/n";
PHP page Jump:
Header ("Location:www.baidu.com");

Several basic concepts of OOP:
Encapsulation: A well-known interface separates the user from the internal workings of the actual application, and when an object (component) is used, it is only necessary to know the form of the interface he provides to the outside world, without having to know the details of his data structure and the algorithm that implements the operation.
Inheritance: Objects of a particular class have all the properties and methods of their generic classes.
Polymorphic: A subclass object can use the same name method as the object of the parent class, and the specific implementation of the method by the different self-class object is determined by itself.

PHP Knowledge Point 2

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.