⊗ppOpStCm 49 of 107 menu

Combination with static in OOP in PHP

A class can contain both static properties and methods, and regular ones.

Let's look at an example. Suppose we have a class Test with both a static property and a regular one:

<?php class Test { public static $staticProperty = 'static'; public $usualProperty = 'usual'; } ?>

Let's work with the regular property of the class:

<?php $test = new Test; echo $test->usualProperty; ?>

And now let's use the static property:

<?php echo Test::$staticProperty; ?>

Create a class that will have both a regular method and a static one.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline