PHP, is the abbreviation of English Super Text preprocessing language hypertext preprocessor. PHP is an HTML embedded language, is a server-side implementation of embedded HTML document scripting language, language style has similar to C language, is widely used. To this end, Preach Wisdom Podcast special free PHP series video Tutorial! For the vast number of PHP beginners and has many years of experience in PHP development programmer, help you in the field of PHP to a higher level!
Course Play Address: http://www.php.cn/course/356.html
The teacher's lecture style:
Teachers teach in a clear, well-organized, layered analysis, interlocking, rigorous argumentation, structural rigorous, with the logical power of thinking to attract students ' attention, with reason to control the course of classroom teaching. Teaching skills, full of wit, all kinds of teaching methods, skills, at ease, just right, and without the slightest trace of the carving.
The most difficult part of this video is: PHP Object-oriented base:
PHP is a very simple language to learn, but the language also includes support for object-oriented programming. Especially with the release of PHP5, PHP has made great progress in object-oriented support. Recently learned a bit of PHP object-oriented programming, can not help feeling, object-oriented really is a very elegant programming, the main thing is really difficult!
Learning to object-oriented, of course, first of all to understand what is a class, what is an object, what is the relationship between classes and objects? The definition of classes and objects is not discussed here, I believe you have a basic understanding of classes and objects. Or is it mainly about the relationship between classes and objects: A class is a template for building objects, and an object is an instance of a class. How to define classes and instantiate objects is not much to say, this is a very simple operation. Here is a simple record of the object-oriented parts of it (many of their own understanding of learning, there is no place to criticize education!) )。
(1) Set the properties of the class: When you have a basic understanding of the class, you will know that different classes have different properties, for example, like commodity, commodity has a price attribute. Defining the properties of a class is not so much the same as defining a variable, especially when defining a property, a keyword that needs to give a visibility to the properties of the class, which determines when the attribute can be accessed. The visibility keywords are public, private, protect, or public, if defined by using Var.
<?phpheader ("content-type:text/html; Charset=utf-8 "), class product{public $name =" shirts "; Public $price = 100;} $product 1=new Product (); Echo $product 1->name;? >
In the above code, the page encoding format is first set to Utf-8, and then a product class is defined, which has two properties: Name, Price, and both of these properties are public, and running this code will output "shirts".
In PHP There is also a dynamic increase in the properties of the operation, $product 1->haha= "haha", directly with the method has been instantiated to access a non-existent property and the method of assignment to dynamically increase the property, the dynamic increase of the property has a big disadvantage is that when the class instantiation of the object, There is no guarantee that other objects also have this property.
(2) The use of methods in the class: the use of the method is to declare the class is possible to use the function, method declaration and function declaration is similar to the method declaration need to precede the method with a visibility keyword, because the visibility of the keyword restrictions, so that the method can be accessed in different places. After declaring a method in a class, we can instantiate an object directly and then use the object to access the method.
<?phpheader ("content-type:text/html; Charset=utf-8 "), class product{public $name =" shirts "; Public $price =100; Public function Say () { return $this->price; }} $product 1=new Product (); Echo $product 1->name. " <br> "Echo $product 1->say ();? >
The above code executes after the browser output: "Shirt", the next line "100". In fact, $this is a pseudo-variable that represents the current object, noting that it represents the current object, not the class.
One of the more important methods in a class is the constructor (also called the constructor), which is called automatically when the object is created and used for instantiation of the object. After PhP5, the constructor is named __construct (), and when we instantiate the object with the new operator, the constructor is called automatically, and the attributes in the class are instantiated according to the parameters to initialize the object. (In fact, the individual feels that this method of construction simply provides an automatic invocation mechanism, when we initialize, the constructor is called automatically, and the parameters are passed in, and the member properties in the class are initialized according to the parameters passed in)
<?phpheader ("content-type:text/html; Charset=utf-8 "); class product{public $name; public $price; Public function __construct ($name, $price) { $this->name= $name; $this->price= $price; } Public function Say () { return $this->price; }} $product 1=new Product ("shirt"), Echo $product 1->name. " <br> "Echo $product 1->say ()." <br> $product 2=new Product (jeans), echo $product 2->say (); >
The above code will output "shirts, 100, 200" in the browser.