⊗ppOpStPr 46 of 107 menu

Static Properties in OOP in PHP

In addition to static methods, you can also create static properties. Such properties are also declared using the keyword static:

<?php class Test { public static $property; } ?>

You can write something to a static property and read from it. The property name is specified with the dollar sign:

<?php Test::$property = 'test'; echo Test::$property; // outputs 'test' ?>

Create a Num class that will have two public static properties: num1 and num2. Write the number 2 to the first property, and the number 3 to the second one. Display the sum of the property values on the screen.

azbydeenesfrkakkptruuz