Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 142 | All time: 9,191 This week: 660![]() |
Version | License | PHP version | Categories | |||
singletonclass 1.0.1 | Custom (specified... | 7 | PHP 5, Language |
Description | Author | |
This class can create, retrieve an delete instances of a class. |
get objects instances by singleton class
require_once('path/to/Singleton.php');
class Test extends Singleton
{
public $test;
// code
}
$test1 = Test::getInstance();
$test1->test = 'test';
function testGetInstance() {
$test = Test::getInstance();
echo PHP_EOL;
var_dump($test->test);
}
testGetInstance();
// output:
// string(4) "test"
require_once('path/to/Singleton.php');
class Test extends Singleton
{
public $test;
}
$test = &Test::getInstance();
$test->test = 'test';
function testCallback() {
$test = &Test::getInstance();
$test = null;
}
echo PHP_EOL;
var_dump($test);
testCallback();
echo PHP_EOL;
var_dump($test);
// output:
// object(Test)#1 (1) {
// ["test"]=>
// string(4) "test"
// }
//
// NULL
![]() |
File | Role | Description |
---|---|---|
![]() ![]() |
Lic. | License text |
![]() ![]() |
Doc. | Documentation |
![]() |
Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.