PracticeStatic methods and properties

Practice: Static methods and properties

In the "Static methods and properties" tutorial, we learned how and when to use static methods and variables. Before we move on to learning about a new feature of the language called tratis, let's practice what we learned.

Let's practice what we have just learned

* Press on the "solution button" to see our suggested solution.

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.
Solution:

Scratchpad to practice your coding *This will not be saved nor submitted to us.*

<?php
//Your practice code
comments powered by Disqus