1. What is class?
Class is a set of related variables and functions;
In class, variables are called attributes, and functions are called methods.
Properties and methods have three features: public, protected, private, and their popular explanations are as follows:
- Public: Common, public, this attribute or method everyone can use ;
- Protected: Protected, this property or method only I and my children and grandchildren (inheritance) can use ;
- Private: This is Lao Tzu's personal, son grandson can not use ;
If you want to use a class, you usually need to instantiate (and also have a static access method), and the class instantiation gets an object
2, the principle of design class (only for this course):
- Must is easy to resuse;
- Must check size (There is max_file_size in the form, but that is easy to get around, so check the size in the script)
- Should restrict permitted types or neutralize risky ones;
- Clean up filenames and optionally prevent overwriting;
- Handle multiple uploads;
- Use a name space (see below) to avoid conflicts with other scripts;
- Inform the user of the outcome;
- Helper methods;
3. Namespaces
Popularly speaking, the namespace is like a folder, class is the equivalent of a file, we can put the same name of the class into a different name space, so do not have to write a long long class file name to avoid the file name conflict. Have time to look for more detailed information, no longer expand here.
Learning Note: Planing the Class ' s features--from:uploading Files securely with PHP