I don't know if it's right or wrong to see something written by others.

Source: Internet
Author: User
I don't know whether it is right or wrong when I see something written by others. we know that the method of writing classes in textbooks is to write a class in a file, I can see that many classes are concentrated in a php file in a project written by others. is this good? is it against the will of textbooks,
I found that many of the things written in reality are different from those in textbooks.
It seems that the readers who write textbooks are deliberately ignoring readers!


Reply to discussion (solution)

In reality, it is not recommended that a file contain multiple classes, but sometimes multiple classes are written according to the actual situation, which should be flexibly used according to the situation.

You can use it easily ..

If the class is automatically loaded through _ autoload or spl_autoload, one file of each class is suitable.

Writing the base class and inheritance class in a file helps to load class files
In this way, there is no need to include files everywhere, and it takes time to read files.

Of course, organizing the directory tree based on the inheritance relationship of classes helps to manage and maintain codes.
Especially when namespace is used

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.