PHP Experiment 4

Source: Internet
Author: User

Experiment Four

1. Create a person class that contains three attribute name,age,wealth, set to public,private,protected, and then define subclass student of the person class.

2. Refer to these three properties in PHP code, a. Used in the person class, B. Outside the person class, C. Used in the subclass student class of the person class. Can not be used properly in these three places? If there is an error, please indicate the error and the cause of the error.

3. Add two methods to the person class above, eat () and consume (), write the test statements, and call both methods in the code. Join the Call Walk () method in the test statement, what are the error hints? How do I fix it? Tip Use magic put __call () to give a friendly hint.

4, in the 2nd question, we are outside the person class directly using the private property is wrong, then what method can be used, without errors? Tip: Magic Methods __set () and __get () methods, add both methods for this class of person. and test that there are no errors in referencing private properties outside of the person class.

5. Test other magic methods, __isset () and __unset ()

PHP Experiment 4

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.