What is the exact difference between functions and classes in PHP

Discussion in 'PHP' started by strgraphics, Jul 26, 2010.

  1. #1
    Any body will explain the exact difference the class and functions in PHP.

    upto now i just worked with functions and i just started the classes so please.
     
    strgraphics, Jul 26, 2010 IP
  2. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    A function performs an action and manipulates data. A class is a collection of functions (actions, methods) and attributes (states, member variables).

    Edit: it's possible to go into great detail about classes, whole books have been written about their design. I decided to keep it to one line :).
     
    Deacalion, Jul 26, 2010 IP
  3. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #3
    If you are using classes, you are creating objects - OOP is very different from procedural programming (which is, typically, about code reuse);

    You might want to have a look at the OOP pages on the official site for more info, though there is *plenty* of information elsewhere shoudl you require it.

    http://php.net/manual/en/language.oop5.php
     
    lukeg32, Jul 26, 2010 IP