static class properties : static properties : Class PHP Source Code


PHP Source Code » Class » static properties »

 

static class properties




<?php

   class visitors
   {
      private static $visitors = 0;

      function __construct()
      {
         self::$visitors++;
      }

      static function getVisitors()
      {
         return self::$visitors;
      }

   }

   $visits = new visitors();
   echo visitors::getVisitors()."<br />";

   $visits2 = new visitors();
   echo visitors::getVisitors()."<br />";

?>

           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Class
» static properties