class usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ok, about five minutes ago i decided to learn classes and delve into php's oop side.

what i came up with was this...

//start example code

class newsletter {
     function send ($email,$subject,$message) {
         if ($email) {
              echo("the following message was sent to: $email <br> subject: $subject<br><br> $message");
         }  
         else {
              echo("failure");
         }
     }
}
$new = new newsletter();
$new->send("test@xxxxxxxxx", "test class", "test class worked, i have passed and failed the test.");

//end code example

..and this seems to work fine, i could easily add  the mail function and insert real variables into send() but what i don't understand is i could also easily do this without a class... so i guess the real question is what are some real life examples of class usage and why is it used as  opposed to regular non oop? thank you for any input into the subject that you may have.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux