本文整理匯總了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;
}
示例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;
示例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'));