Example Analysis of member method in PHP object-oriented
Editor to share with you the PHP object-oriented member method of the example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
Use a Liezi to read and understand the member method: you can write it yourself to deepen your understanding.
Such a need; I want people to be able to talk and do arithmetic, so we need to use the member method:
1. Add the speak member method, and output that I am Xiao Ming
2. Add a jisuan member method to calculate the result from 1. 1000.
3. Modify the jisuan member method, which can receive a number n and calculate the result of 1 percent.
4. Add add member method to calculate the sum of two numbers.
Reference Code:
The copy code is as follows:
The above is all the content of the article "sample Analysis of member methods in PHP object-oriented". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!