1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php class mathematics{ public function addTwo(){ return $this->num+2; } }/*** end of class ***/ /*** Instantiate a new class instance ***/ $math = new mathematics; /*** set the value of the number ***/ $math->num = 2; /*** call the addTwo method ***/ echo $math->addTwo(); ?> |
![wordpress category](https://www.codehaven.co.uk/wp-content/uploads/2018/12/wp12-1.png)