PHP Classes

Needed changing to suit my individual needs, as expected.

Recommend this page to a friend!

      MIME E-mail message sending  >  All threads  >  Needed changing to suit my...  >  (Un) Subscribe thread alerts  
Subject:Needed changing to suit my...
Summary:Package rating comment
Messages:6
Author:Phil
Date:2008-07-25 13:29:31
Update:2008-08-02 05:33:04
 

Phil rated this package as follows:

Utility: Good
Consistency: Good
Documentation: Good
Examples: Good
Unit tests: Good

  1. Needed changing to suit my...   Reply   Report abuse  
Picture of Phil Phil - 2008-07-25 13:29:31
Needed changing to suit my individual needs, as expected. Otherwise, a perfect script, and an outstanding and easy to follow framework. Thanks!

  2. Re: Needed changing to suit my...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-25 18:33:32 - In reply to message 1 from Phil
The class is very generic. What kind of needs do you have that require changing the class?

  3. Re: Needed changing to suit my...   Reply   Report abuse  
Picture of Phil Phil - 2008-07-28 08:16:18 - In reply to message 2 from Manuel Lemos
We're using the script to mass mail a couple of thousand addresses for publicity for a conference centre (not spam!!). Thus, after each successful send we update a database with the mailing id (got from the /var/log/mail mailing log) and the sent time. Yes, this could be done outside of the class but this way once the class is called, everything is within the calling function and the class.

Once again, thanks for a brilliant script.

  4. Re: Needed changing to suit my...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-28 08:26:02 - In reply to message 3 from Phil
You do not need to change the class to do that.

Even if you insist in doing your stuff from inside the call to the Send() function, what you can do is to create a sub-class with a Send() function, call the parent::Send() function, and do your stuff after it returns.

This way you will not have problems to merge your changes when a new version of this class is released.

  5. Re: Needed changing to suit my...   Reply   Report abuse  
Picture of Phil Phil - 2008-08-01 15:04:05 - In reply to message 4 from Manuel Lemos
Hey,
Thanks for the help there, I'm sure it's great advice. Unfortunately, I'm not entirely sure what you mean with it!!

Having only been programming a few months with classes, it'd be a great help if you could expand on this?

How does one create a subclass? Is this a separate class to the main class? Or adding functions into the main class? Or even a class-within-a-class?

Thanks for your help

  6. Re: Needed changing to suit my...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-08-02 05:33:04 - In reply to message 5 from Phil
A sub-class is a new class that inherits all the functions and variables of the parent class. You declare it like this:

class my_email_message_class extends email_message_class
{
Function Send()
{
$success = parent::Send();
return($success);
}
};

The sub-class above extends the parent class email_message_class.

The function Send() is replaced by a new function Send() that calls the parent class Send() function.

You can change this sub-class Send() function to add your stuff.

Nothing changes in your application except that you need to use the new sub-lcass name in the class object creation like this:

$message = new my_email_message_class;