PHP code example of alireaza / singleton
1. Go to this page and download the library: Download alireaza/singleton library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alireaza / singleton example snippets
use AliReaza\Singleton\Singleton;
class WhoAmI extends Singleton
{
public string $name = 'What\'s my name?';
}
$who = WhoAmI::getInstance();
$who->name = 'AliReaza';
$alireaza = WhoAmI::getInstance();
echo $alireaza->name; // AliReaza