Closed Thread
Results 1 to 2 of 2

Thread: [PHP] Intialized class and not-initialized class, differences?I

  1. #1
    Jacki's Avatar
    Jacki is offline Learning Programmer
    Join Date
    Sep 2009
    Location
    Switzerland
    Posts
    80
    Rep Power
    9

    [PHP] Intialized class and not-initialized class, differences?I

    hi people,
    I have a simple question. I have two ways to use a class in php:
    Code:
    //initializing object
    $myclass = new myClass;
    // or not initializing class..

    $myclass->myfunction();
    myClass::myfunction(); 
    What are the differences? When I have to use one and when i have to use the other? Thanks... bye!



  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: [PHP] Intialized class and not-initialized class, differences?I

    if you instansiate an object from the class, as you do in your first example, it will be initialized as well, having it's constructor done, creating an object of it's members and methods. with this object, you can perform different things as in your second codeline.

    second line of yours will only work on instansiated objects, and that normally performs an action on that object, or retirns info from the object.

    third line is what most call a static call to a method, usually a method that does not rely on anything else in the class, that just performs a calculation or what it is meant to do.
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 10-21-2011, 08:21 AM
  2. Passing a class variable to another class
    By lor in forum C and C++
    Replies: 1
    Last Post: 06-01-2011, 12:27 PM
  3. Replies: 2
    Last Post: 03-30-2011, 07:13 PM
  4. Replies: 4
    Last Post: 06-30-2010, 09:22 PM
  5. Replies: 4
    Last Post: 04-20-2008, 07:32 AM

Tags for this Thread

Bookmarks

Posting Permissions

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