use StaticSet\StaticSet; class HttpErrors extends StaticSet { const NOT_FOUND = 404; const SERVER_ERROR = 500; } // Use the static set in your code if ($status == HttpErrors::NOT_FOUND) { // handle 404 error } elseif ($status == HttpErrors::SERVER_ERROR) { // handle 500 error }
use StaticSet\StaticSet; class AppConfig extends StaticSet { const DB_NAME = 'myapp_db'; const DB_USER = 'myapp_user'; const DB_PASSWORD = 'myapp_password'; } // Use the static set to access configuration parameters $database = new PDO('mysql:host=localhost;dbname=' . AppConfig::DB_NAME, AppConfig::DB_USER, AppConfig::DB_PASSWORD);In both examples, the StaticSet library is used to define a set of static values and access them throughout the code. The library provides a convenient way to define and manage these sets of values. The package library for PHP Static Set is available on Packagist as "mlocati/static-set" and can be installed using Composer.