Static function and member variables

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
srikanth03565
Forum Newbie
Posts: 10
Joined: Sat Jul 16, 2011 12:13 am

Static function and member variables

Post by srikanth03565 »

Hi
Can any one explain Advantages and disadvantages of static functions and its member variables.(Any language with respect to OOPS)
I have studied this on lot of sites but no one explained exact reasoning.

Why they are fast and how they are actually executed

Thanks
Srikanth Reddy
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Static function and member variables

Post by Jonah Bron »

There aren't really "advantages and disadvantages", because they're not really comparable. They have different purposes. Sometimes you need to associate a method/property with an instance (i.e. an instance method/property), and sometimes you need to associate it with the class itself (i.e. a static method/property). I asked a question very similar to this a while back, and got some great answers.

viewtopic.php?t=127667
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Static function and member variables

Post by Christopher »

The problem with static functions and their member variables are the same problems with globals and functions in general. So read up on the disadvantages of globals and procedural programming. The advantages is that they are quick and easy.
(#10850)
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: Static function and member variables

Post by Jenk »

OOPS?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Static function and member variables

Post by Christopher »

Jenk wrote:OOPS?
Object Oriented Programming Statically :drunk:
(#10850)
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Static function and member variables

Post by Jonah Bron »

I'll drink to that :D :drunk:
Post Reply