Example #1
0
    private $result = 1;
    //private $number;
    function __construct($number)
    {
        $this->number = $number;
        for ($i = 2; $i <= $number; $i++) {
            $this->result *= $i;
        }
    }
    public function showResult()
    {
        echo "Factorial of {$this->number} is {$this->result}. ";
    }
}
$fact = new Factorial(8);
$fact->showResult();
//class.statictester.php
class StaticTester
{
    private static $id = 0;
    function __construct()
    {
        self::$id += 1;
    }
    public static function checkIdFromStaticMehod()
    {
        echo "Current Id From Static Method is " . self::$id . "\n";
    }
    public function checkIdFromNonStaticMethod()
    {
        echo "Current Id From Non Static Method is " . self::$id . "\n";
Example #2
0
include_once 'class.wordcounter.php';
include_once 'class.htmlemailer.php';
include_once 'class.dbmanager.php';
include_once 'class.statictester.php';
include_once 'class.student.php';
include_once 'class.overloader.php';
/*----------  Extended Emailer  ----------*/
$emailerobject = new ExtendedEmailer();
$emailerobject->setSender('*****@*****.**');
$emailerobject->addRecipients('*****@*****.**');
$emailerobject->setSubject('Just a Test');
$emailerobject->setBody('Content of Email');
$emailerobject->sendEmail();
/*----------  Factorial  ----------*/
$factorial = new Factorial(5);
$factorial->showResult();
/*----------  WordCounter  ----------*/
$count = new WordCounter('words.txt');
$count->count(WordCounter::ASC);
/*----------  HTML Emailer  ----------*/
$newemailerobject = new HtmlEmailer('wdarking');
$newemailerobject->addRecipients('*****@*****.**');
$newemailerobject->setSubject('*****@*****.**');
$newemailerobject->setBody('Hi there :D');
$newemailerobject->sendEmail();
$newemailerobject->sendHtmlEmail();
/*----------  DBDriver  ----------*/
$dbdriver = DBManager::getMySQLDriver();
/*----------  Static Tester  ----------*/
$tester = new StaticTester();
print "<br>";