Intro to PHP's avatar
Intro to PHP
Blog
Jason's avatar
May 2nd, 2011 by Jason T

<?php

class Email
{
    const TYPE_TEXT = 1;
    const TYPE_HTML = 2;
   
    public static function send ($options)
    {
        global $_db;
       
        $from = $options['from'];
       
        $options['content_type'] = $options['content_type'] == self::TYPE_TEXT
            ? 'text/plain'
            : 'text/html';
               
        $headers  = 'MIME-Version: 1.0' . "n";
        $headers .= "Content-type: $options[content_type]; charset=UTF-8n";
        $headers .= "From: $fromn";
        if ($options['bcc'])
            $headers .= "Bcc: $options[bcc]n";
        if ($options['cc'])
            $headers .= "Cc: $options[cc]n";
        $headers .= "Reply-To: $fromn";
       
        if ($options['to'] && $options['subject'] && $options['body'])
        {
            return mail($options['to'], $options['subject'], $options['body'], $headers)
                ? TRUE
                : FALSE;
        }
       
        return FALSE;
    }
}

?>

 

To use this class, be sure to require the classfile.  Something like:

require "class_email.php";

 

Then, use something like this to use it:

$send_email = Email::send(array(
                            'from' =>             'orders@technosworld.com',
                            'to' =>                $recipient,
                            'bcc' =>            $bcc,
                            'content_type' =>    Email::TYPE_HTML,
                            'subject' =>        $subject,
                            'body' =>            $body
));

Anyone can view this 0 Comments Add Comment
Jason's avatar
February 22nd, 2011 by Jason T

Looks like most of you did really well on test 2...  Good job!


Part 1 had you looking for errors, standards, and logic issues in a premade script.  I was looking for 13 different issues to be solved.  Everyone started with 40 points and lost up to 3 points for each issue not addressed or addressed wrong.  The average score for part 1 was 34.2 points or 86%.


Part 2 asked you to create a script for entering transaction data for a budgeting application.  I was looking at 11 areas for 5 points each except one which was worth 10 points.  Everyone started with 60 points and points were deducted for problems in each of the areas if there were any.  The average score for part 2 was 44 points or 73%.


The average test score overall was 78 points out of 100.

Anyone can view this 0 Comments Add Comment
Jason's avatar
January 27th, 2011 by Jason T

 If you are still with us, then you made it past Test 1.  Congratulations!  While I am generally pleased with the results, I want to take a few moments to go over the statistics and give you some thoughts...

Part 1:

30 points possible -- Average was 19.9 points or 66%

Part 2:

30 points possible -- Average was 25.5 points or 85%

Part 3:

40 points possible -- Average was 30.4 points or 76%

Overall Without Extra Credit

Overall average score with all parts and no extra credit factored in was 76%

Extra Credit

25 points possible -- Points ranged from 4 to 25 for those that attempted it

Overall With Extra Credit

Overall average score with all parts and extra credit factored in was 89.9%

I think that all things considered it was a good test and you all did pretty well.  It does look like we need to work more on identifying errors in syntax, coding standards, and logic however.  I want you guys to become very good at eliminating errors so we will work more on that.  Also, next time, I will try to make the format of how I test for that a little more clear and easy.

Good Job!

Anyone can view this 0 Comments Add Comment
Jason's avatar
January 27th, 2011 by Jason T

I finally got around to creating a decent page for the class.  I will ** try ** to maintain it and make it useful.  At the very least, I will be posting the PowerPoint slides you will need.  I admit up front that maintaining such a website is not a strength of mine, but give me a couple chances here and I will really try hard :)  Keep checking back for the latest news and info...

Anyone can view this 0 Comments Add Comment
Latest Blog Entries
PHP: An Email Class
May 2nd, 2011
Test 2 Results
February 22nd, 2011
Test 1 Results
January 27th, 2011
 

CTEC 110: Command Line Essentials
CTEC 127: Intro to PHP
CTEC 227: Advanced PHP

Instructor: Jason "Techno" Timm
Office: Salmon Creek
Email: jasontimm@gmail.com
 
© Copyright 2011   Technosworld.com. All Rights Reserved. Login