Results 1 to 10 of 10

Thread: classes question

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    classes question

    I am working on a class, and Penagate told me i should use Public Static Function for one of my functions, but i am not sure when i need to use them and when not to use them.

    Explain
    My usual boring signature: Something

  2. #2
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: classes question

    Static means that function can be called without needing a member variable.
    ie
    class::function();
    However if you don't have public static, you need to use:
    $var = new class();
    $var->function();

    See for more info: http://www.php.net/manual/en/language.oop5.static.php
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  3. #3

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: classes question

    thanks for that. The link helped a little
    My usual boring signature: Something

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: classes question

    You own a kettle producing factory (congratulations on your acquisition). To stream line processes you create a plastic mould that determines the shape of a particular model (class) of kettle. From this you can make many kettles (instances) which all boil your water.

    Stamped to the outside of each of your moulds is a model number, in order to view this model number you look at the plastic mould. In order to boil water however or look at the serial number of a kettle itself (an instance) you must look at the actual kettle that the mould produced it. The mould does not contain the serial numbers, nor does it boil water.

    Thus, a class member (static member) is an attribute or behaviour that is not associated with an object of that class but with the class itself. For example you may wish to use a a common file in which all your classes are serialized after use and restored before use. A static attribute could be used to store the file name and a static function to restore and save the instances of that class.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: classes question

    that confused me even more. Can you use like... gummy worms or something?
    My usual boring signature: Something

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: classes question

    What is confusing? It is analogy . Just replace kettle with gummy worms?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: classes question

    i dont boil water with gummy bears. Go online and explain to me
    My usual boring signature: Something

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: classes question

    Quote Originally Posted by dclamp
    i dont boil water with gummy bears. Go online and explain to me
    I swear I wrote that post in English but clearly you are reading too far into it or you have interpreted it as Panda
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: classes question

    User class deals with users. Some functions don't apply to any particular user but either to the set of all users as a whole, or to no users: these should be static members. Some functions apply to one particular user: these should be non-static.

    Some examples: add user (static, because it results in a new user object), delete user (non-static, because you have a user object to begin with), authenticate (could be either static or non-static, depending on your personal design preference), log out (non-static).

  10. #10

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: classes question

    ok that makes sense to me. Thanks for going over that pena.
    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width