A class is a collection of variables and functions that act on those variables. Define a class using the following syntax.
php class
class class name {
# Class's implementation #membership #package function #member method}
1) Class names can only use letters, starting with an underscore , and cannot begin with a number
2) Class names cannot use keywords
3) The class name must be meaningful
4) Class names are not case sensitive, but it is best to use camel case
userModel UserModel
5) Class names cannot be duplicated
6) Class Connect {} Empty class, what is the meaning of the empty function, the empty class is an interface reserved for later project expansion
Class is
The pseudo variable $ this is usually undefined if its method is statically called. But this is not a strict rule: if a method is called statically from within another object, $ this will be defined. The value of $ this is the object that made the call. Use the following example to demonstrate:
<? phpclass A {function foo () {if (isset ($ this)) {echo '$ this is defined ('; echo get_class ($ this); echo ") / n";} else {echo "/ $ this is not defined./n ";}}} class B {function bar () {A :: foo ();}} $ a = new A (); $ a-> foo (); A :: foo () ; $ b = new B (); $ b-> bar (); B :: bar ();?> The above example will output:
$ this is defined (a) $ this is not defined. $ this is defined (b) $ this is not defined.