{[ .singleton | 1.hilite(=php=) ]}
Example
{[ .example | 1.hilite(=php=) ]}
Results
Now C holds world
Now A holds 3
Now AA holds world10
Now A holds 5
Now AA holds 5
AA() is A() ? No
Singleton::instance(‘A’) is A() ? Yes
Andrea Ercolino, Software Engineer
{[ .singleton | 1.hilite(=php=) ]}
Example
{[ .example | 1.hilite(=php=) ]}
Results
Now C holds world
Now A holds 3
Now AA holds world10
Now A holds 5
Now AA holds 5
AA() is A() ? No
Singleton::instance(‘A’) is A() ? Yes
I think you should use the ReflectionClass to initialize the instance of $class with arguments
Example:
in the instance() function you call
$instance = new $class( $args );
in this case $args is an array and that is not what the constructor of $class expects as arguments
Solution:
$reflection = new ReflectionClass( $class );
$instance = $reflection->newInstanceArgs( $args );
Sorry for my bad english.
I hope you understand me 😉