當前位置: 首頁>>代碼示例>>PHP>>正文


PHP C::doSomething方法代碼示例

本文整理匯總了PHP中C::doSomething方法的典型用法代碼示例。如果您正苦於以下問題:PHP C::doSomething方法的具體用法?PHP C::doSomething怎麽用?PHP C::doSomething使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在C的用法示例。


在下文中一共展示了C::doSomething方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doSomething

    }
    public function doSomething()
    {
        return 'Something';
    }
    public function aGenericMethod()
    {
        return 9000;
    }
    public function mixItUp()
    {
        return parent::aGenericMethod() . ' ' . parent::doSomething() . ' ' . $this->doSomething();
    }
}
$a = new A();
$b = new B();
$c = new C();
$p = new TablePrinter(['Method', 'Result']);
$p->addRow("A::aGenericMethod()", $a->aGenericMethod());
$p->addRow("B::aGenericMethod()", $b->aGenericMethod());
$p->addRow("C::aGenericMethod()", $c->aGenericMethod());
$p->addRow("B::doSomething()", $b->doSomething());
$p->addRow("C::doSomething()", $c->doSomething());
$p->addRow("C::mixItUp()", $c->mixItUp());
$p->output();
echo "\n\n";
$p = new TablePrinter(['Class', 'setting', 'anotherSetting']);
$p->addRow("A", print_r($a->setting, true), print_r($a->anotherSetting, true));
$p->addRow("B", print_r($b->setting, true), print_r($b->anotherSetting, true));
$p->addRow("C", print_r($c->setting, true), print_r($c->anotherSetting, true));
$p->output();
開發者ID:elagith,項目名稱:learningMaterial,代碼行數:31,代碼來源:Example.php

示例2: Application

$logger1 = new Gelembjuk\Logger\FileLogger(array('logfile' => $logfile, 'groupfilter' => 'all'));
// pass created logger as argument
// after object created and the method called you will see logs in your log file
// at this moment all logs are written
$application1 = new Application($logger1);
$application1->doSomething();
// now wee loggeing from the class B
$b1 = new B($logger1);
$b1->doSomething();
// this shows how to use logger from other class where the trite is used
// object of this class must be set to $this->application property
$c1 = new C($application1);
$c1->doSomething();
unset($application1);
unset($b1);
unset($c1);
// ****** TEST 2 ******
// don't use existent logger, but create it inside
$application2 = new Application(null);
// we set filtering to `construct`. So only logs from constructors will be saved
$application2->initLogger(array('logfile' => $logfile, 'groupfilter' => 'construct'));
$application2->doSomething();
// get logger object reference from application
$b2 = new B($application2->getLogger());
$b2->doSomething();
// this usage is same as above. Doesn't mapper how application created logger
// this class will just reuse it
$c2 = new C($application2);
$c2->doSomething();
$logger = $application2->getLogger();
echo "Now see to your log file!";
開發者ID:gelembjuk,項目名稱:logger,代碼行數:31,代碼來源:index.php


注:本文中的C::doSomething方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。