Spyware Techie

|

Spyware Techie


Security Inspector 2010 Removal Guide

Posted: 08 Nov 2010 04:24 AM PST

Do you know what Security Inspector 2010 is? Security Inspector 2010 is not only a dangerous rogue but also part of a big money stealing plan. This means that if your computer...

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]

System Lock 2011 Removal Guide

Posted: 08 Nov 2010 04:20 AM PST

Do you know what System Lock 2011 is? The moment that System Lock 2011 shows you signs and symptoms is the moment when you need to seriously think about removing System Lock...

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]

Nice to write to you

|

Nice to write to you
My name is Miss mabell , As I whisper my prayer tonight and went into search for a nice friend at google that is(internet) I came across your contact,My mind and my heart told me to contact you for friendship, A friend who truly understand his or her friend and share their feelings together. please kindly accept my request, I believe that distance or age can never be a barrier but let's love connect us because love is a bridge that connected far distance to be close to each other, I will send my pictures to you immediately i receive your reply at my email address
mabell42009@hotmail.com
         yours In Love,
         mabell
mabell42009@hotmail.com

Latest Security News | SecurityExtra.com

|

Latest Security News | SecurityExtra.com


IED Discoveries Prompt State of Alert Amongst Counter-Terrorism Community

Posted: 06 Nov 2010 10:06 AM PDT

The discovery on Friday of two Improvised Explosive Devices (IEDs) already in transit to target through the airfreight transportation system, has prompted a near global clampdown on the movement of cargo from the Yemen, fear that more such devices may be en-route or have reached target and a manhunt for the master bomb maker thought [...]

Programming Tutorials and Developer Forums

|

Programming Tutorials and Developer Forums


PHP 5 Tutorials – Static Data Members and Methods

Posted: 12 Feb 2008 01:47 AM PST

In this tutorial you will learn all about static data members and methods

  • Meaning of static data members
  • Meaning of static methods
  • Defining static data members in PHP5
  • Defining static methods in PHP5
  • Accessing static data members in PHP5
  • Accessing static methods in PHP5
  • Rules to keep in mind for static methods

Meaning of static data members

A data member that is commonly available to all objects of a class is called a static member. Unlike regular data members, static members share the memory space between all objects of the same class.

Meaning of static methods

A static method is a class method that can be called without creating an instance of a class. Such methods are useful when creating utility classes.




Defining static data members in PHP5

To define a static member in PHP5 you need to prefix the class member name with the keyword ‘static’. Look at the example below.

  class Customer {   	private $first_name; // regular member 	static public $instance_count; //static data member   }

In the above example $instance_count is declared as a static data member

Defining static methods in PHP5

To define a static data methods in PHP5 you need to prefix the class method name with the keyword ‘static’. Look at the example below.

  class Customer {   	public function getFirstName() { 		//body of method 	}   	static public function getInstanceCount() { 		//body of method 	} }

In the above example getInstanceCount is declared as a static method

Accessing static data members in PHP5

A static member data can be accessed using the name of the class along with the scope resolution operator (::) i.e. you don’t need to create an instance of that class

Look at the example below:

  class Customer {   	static public $instance_count = 0; //static data member   	public function __construct() { 		Customer::$instance_count++; 	}   	public function __destruct() { 		Customer::$instance_count--; 	}   	public function getFirstName() { 		//body of method 	}   	static public function getInstanceCount() { 		//body of method 	} }   $c1 = new Customer(); $c2 = new Customer();   echo Customer::$instance_count;

Output:
2

In the above example, $instance_count is a static data member. Every time a new object is created the constructor is executed and the $instance_count variable is incremented by one. To echo the value contained in $instance_count variable, we use the :: (scope resolution) operator.




Accessing static method in PHP5

A static method can be accessed using the name of the class along with the scope resolution operator (::) i.e. you don’t need to create an instance of that class. However, you can also access it with an instance variable.

Look at the example below:

  class Customer {   	static public $instance_count = 0; //static data member   	public function __construct() { 		Customer::$instance_count++; 	}   	public function __destruct() { 		Customer::$instance_count--; 	}   	public function getFirstName() { 		//body of method 	}   	static public function getInstanceCount() { 		return Customer::$instance_count; 	} }   $c1 = new Customer(); $c2 = new Customer();   echo Customer::getInstanceCount(); //this is using the scope resolution operator echo $c1->getInstanceCount(); //this is using the instance variable

Output:
2
2

Rules to keep in mind for static methods

  • A static method can only access static data members
  • A static method does not have access to the $this variable

Please feel free to write back for any clarification.

Subscribe to my newsletter:

Related Posts on PHP5 Tutorial – Object Oriented Programming (OOPS)

  1. PHP5 Tutorial – Learn to create a PHP5 Class
  2. PHP5 Tutorial – Learn to Create a PHP5 Class Object
  3. PHP5 Tutorial – Defining Attributes of a PHP5 Class
  4. PHP5 Tutorial – Defining Methods of a PHP5 Class
  5. PHP5 Tutorial – Creating a PHP5 Constructor __construct()
  6. PHP5 Tutorial OOPS – Creating a PHP5 Destructor __destruct()
  7. PHP5 Tutorial OOPS – PHP5 Class Access Specifiers – public, private and protected
  8. PHP5 Tutorial – $this variable explained
  9. PHP5 Tutorial – instanceOf Operator Explained
  10. PHP5 Tutorial – Defining Class Constants
  11. PHP5 Tutorial – Inheritance
  12. PHP5 Tutorials – Abstract Class and Interface
  13. PHP5 OOPS Tutorials – Polymorphism
  14. PHP5 Tutorial – Magic Methods – __toString() method
  15. PHP5 Tutorial – Magic Methods – __get() and __set()
  16. PHP5 Tutorial – Magic Methods – __isset() and __unset()
  17. PHP5 Tutorial – Magic Methods – __call() method
  18. PHP5 Tutorial – Magic Methods – __autoload() method
  19. PHP5 Tutorial – Magic Methods – __sleep() and __wakeup()
  20. PHP5 Tutorial – Magic Methods – __clone() method

 

©2009 Programming & Security | Template Blue by TNB

Vida de bombeiro Recipes Informatica Humor Jokes Mensagens Curiosity Saude Video Games Diario das Mensagens Eletronica Rei Jesus News Noticias da TV Artesanato Esportes Noticias Atuais Games Pets Career Religion Recreation Business Education Autos Academics Style Television Programming Motosport Humor News The Games Home Downs World News Internet Design Entertaimment Celebrities 1001 Games Doctor Pets Net Downs World Enter Jesus Mensagensr Android Rub Letras Dialogue cosmetics Genexus Só Humor Curiosity Gifs Medical Female American Health Madeira Designer PPS Divertidas Estate Travel Estate Writing Computer Matilde Ocultos futebolcomnoticias girassol lettheworldturn topdigitalnet Bem amado enjohnny produceideas foodasticos cronicasdoimaginario downloadsdegraca compactandoletras newcuriosidades blogdoarmario arrozinhoii sonasol halfbakedtaters make-it-plain amatha lisboaohyeah lasofia thebushrajr wingshock tripedes gorduravegetal dainfamia dejavu-transpersonal jsbenfica republicadasbadanas ruiherbon iranianforaryans eaystcheyl fotosdanadir ojosmasabiertos ceilasantos