Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Person{
- public static $total_people = 0;
- private $name = "";
- function __construct($name){
- $this->name = $name;
- self::$total_people++;
- }
- public function sayName(){
- print($this->name."\n");
- }
- public static function peopleCount(){
- print(self::$total_people."\n");
- }
- }
- $john = new Person("John");
- $john->sayName(); //prints john
- Person::peopleCount(); //prints 1
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement