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


PHP Factory::factory方法代碼示例

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


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

示例1: getFactory

 public function getFactory()
 {
     if ($this->factory == NULL) {
         $this->factory = Factory::factory();
         $this->factory->registerType('resource', 'ResourceController');
         $this->factory->registerType('service', 'ServiceController');
         $this->factory->registerType('users', 'UserController');
         $this->factory->registerType('apps', 'ClientAppController');
     }
     return $this->factory;
 }
開發者ID:rosko,項目名稱:AlmazService,代碼行數:11,代碼來源:ApiController.php

示例2: Factory

<?php

require_once './libs/Autoload.class.php';
/*spl_autoload_extensions(".php,.class.php");
	set_include_path(get_include_path() . PATH_SEPARATOR . '/libs/');*/
spl_autoload_register('autoload');
error_reporting(E_ALL & ~E_NOTICE);
$numA = $_POST['numA'];
$sign = $_POST['sign'];
$numB = $_POST['numB'];
$obj = new Factory($sign);
$result = $obj->factory()->getResult($numA, $numB);
echo $result;
開發者ID:ryanlee1992,項目名稱:Caculator,代碼行數:13,代碼來源:Result_autoload1.php

示例3: __construct

{
    private static $instance;
    private function __construct($a, $b, $c)
    {
        echo 'Product52 ', $a, $b, $c, " <br/>\n";
    }
    public static function __instance($a, $b, $c)
    {
        if (!isset(self::$instance)) {
            self::$instance = new self($a, $b, $c);
        }
        return self::$instance;
    }
}
class Product5Factory
{
    public static function factory($a = null, $b = null, $c = null)
    {
        if ($a && $b && $c) {
            return Product52::__instance($a, $b, $c);
        }
        return new Product51();
    }
}
$product1 = Factory::factory('Product1');
$product2 = Factory::factory('Product2', array('a', 'b', 'c'));
$product3 = Factory::factory('Product3', null, '__instance');
$product4 = Factory::factory('Product4', array('a', 'b', 'c'), '__instance');
$product51 = Factory::factory('Product5');
$product52 = Factory::factory('Product5', array('a', 'b', 'c'));
開發者ID:manachyn,項目名稱:trainings,代碼行數:30,代碼來源:Factory2.php


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