Using a column to read and understand Members: You can write and understand it by yourself.
This is a requirement. Hope that people can talk and do arithmetic questions... so that they need to use the member method:
1. Add the Speak member method. The output is James.
2. Add the jisuan member method to calculate the result from 1 +... + 1000
3. Modify the jisuan member method. This method can receive a number N and calculate the result of 1 +... + N.
4. Add a member method to calculate the sum of two numbers
ReferenceCode:
<? PHP Class Person { Public $ Name ; Public $ Age ; // Add member Method Public Function Speak (){ Echo "I'm James" ;} Public Function Jisuan (){ // Calculate the result from 1 +... + 1000 $ Result = 0 ; For ( $ I = 1; $ I <= 1000; $ I ++ ){ $ Result + = $ I ;} // Returns the calculated result ruturn. Return $ Result ;} Public Function Jisuan2 ( $ N ){ // Calculate the result from 1 +... + n $ Result = 0 ; For ( $ I = 1; $ I <= $ N ; $ I ++ ){ $ Result + = $ I ;} // Return Return $ Result ;} // Calculate the sum of two numbers Public Function Add ( $ Num1 , $ Num2 ){ Return $ Num1 + $ Num2 ;}} $ Person1 = New Person; // People speak $ Person1 -> Speak (). '<br/>' ; // Computing Echo '<Br/> '. $ Person1 -> Jisuan (); // Echo '<br/>'. $ person1-> jisuan (100); // with Parameters Echo 'The calculated result is :'. $ Person1 -> Jisuan2 (5); // Calculate the sum of two numbers Echo "<Br/> 50 + 50 = ". $ Person1 -> Add (50, 51 ); ?>