The use of static methods and variables is appropriate in the following cases:
- A Whenever we want to use a class's method without instantiation.
- B For utilities such as conversion between units of measurements, sanitation, encryption, etc.
- C When we would like to unit test our code.
- D When our code is static.
BWe might consider the use of static methods and variables when we need utility methods, with some common uses being: counters, sanitation, encryption, unit conversion, and any other methods that only give services to our program's main classes.
Scratchpad to practice your coding *This will not be saved nor submitted to us.*
<?php
//Your practice code