예제 #1
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";
    }
}
$st1 = new StaticTester();
StaticTester::checkIdFromStaticMehod();
$st2 = new StaticTester();
echo "<br/>";
$st2->checkIdFromNonStaticMethod();
echo "<br/>";
abstract class AbstractClass
{
    // Our abstract method only needs to define the required arguments
    protected abstract function prefixName($name);
}
class ConcreteClass extends AbstractClass
{
    // Our child class may define optional arguments not in the parent's signature
    public function prefixName($name, $separator = ".")
    {
        if ($name == "Pacman") {
            $prefix = "Mr";
예제 #2
0
$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>";
StaticTester::checkIdFromStaticMethod();
print "<br>";
$tester2 = new StaticTester();
$tester->checkIdFromNonStaticMethod();
print "<br>";
$tester->checkIdFromStaticMethod();
print "<br>";
$tester2->checkIdFromNonStaticMethod();
print "<br>";
$tester3 = new StaticTester();
StaticTester::checkIdFromStaticMethod();
print "<br>";
/*----------  Student  ----------*/
$student = new Student();
$student->name = "Gilmar";
$student->roll = 19;
print "{$student->name}<br>";
print "{$student->roll}<br>";