Created
August 25, 2021 12:42
-
-
Save Vijaysinh/838ceafd9dbdad75197a6d87219e48d6 to your computer and use it in GitHub Desktop.
Count How many time class instance got created
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Count How many time class instance got created | |
class classA { | |
public static $counter = 0; | |
function __construct(){ | |
self::$counter++; | |
} | |
} | |
$obj1 = new classA(); | |
$obj2 = new classA(); | |
echo classA::$counter; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment