Development thinking and example Analysis of PHP object-oriented programming

Source: Internet
Author: User
Tags php class
In our process of learning PHP, object-oriented is an essential part, many small partners are ambiguous to object-oriented, learning object-oriented, of course, first of all to understand what is a class, what is the object, class and object what is the relationship? Class and object relationships: A class is a template used to build an object, and an object is an instance of a class. I believe this people have a better understanding, today we will introduce PHP object-oriented Programming development!

The first step is to download the PHP object-oriented Programming class library that we need to use for this lesson: http://www.php.cn/xiazai/leiku/618

The second step, after the download, find the PHP class files we need, unzip to our local directory, create a new PHP file!

After the third step, we will call this class in the new PHP file, and instantiate the class:

<?phpinclude_once "dingyi3.php";//Introduce class file//Instantiation $person1 = new Person (), $person 2 = new Person ("2"), $person 3 = new Perso N ("3");//__set () $person 1->name = "Zhang San"; Echo $person 1->name;echo "<br/>"; Echo $person 1->say ();//From __get () echo $person 1->age;echo "<br/>"; Var_dump (Isset ($person 1->name)); echo "<br/>"; unset ($ Person1->name); echo "unset------------>". $person 1->name;//name not been unset () echo "<br/>"; $person 2 = null;? >

Run the file and get the results as shown:

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.