Define Show Class
class defines the method sum
Two numbers passed in the method
Within the method body, all even-numbered and two numbers are calculated
The results will be calculated to return
Results after output return
The output form is as follows
Two numbers between all even-numbered and: 30
Note: The incoming two number is smaller than the first incoming large number of the second incoming two numbers cannot be equal.
The code is as follows:
$two) {for ($i = $two; $i <= $one; $i + +) {if ($i%2==0) {$num + = $i;}} else if ($two > $one) {for ($i = $one; $i <= $two; $i + +) {if ($i%2==0) {$num + = $i;}} Else{return "error, two numbers cannot be equal";//If two numbers equal}return "two number of all even numbers and for". $num;}} Instantiate class $show=new Show ();//Call echo $show->sum (20,30);//Enter two values
The above introduces PHP to find out two of the sum of all the even, including PHP, between the content, I hope to be interested in PHP tutorial friends helpful.