本文整理汇总了PHP中config::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP config::getInstance方法的具体用法?PHP config::getInstance怎么用?PHP config::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config
的用法示例。
在下文中一共展示了config::getInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($instanceName, $configName=null) {
//populate the needed connection information from the config.ini file
$this->instanceName = $instanceName;
$config = config::getInstance($configName);
$this->hostname = $config->get('hostname');
$this->username = $config->get('username');
$this->password = $config->get('password');
$this->database = $config->get('database');
$this->db = mysql_connect($this->hostname, $this->username, $this->password) or die("There was an error conntecting to the database:".$this->database." on server: ".$this->hostname." for user:".$this->username);
$selectedDB = mysql_select_db($this->database, $this->db) or die("There was an error selecting the database");
}
示例2: __construct
private function __construct()
{
$this->config = config::getInstance();
$this->db = db::getInstance();
$this->adapter = new Smarty();
$this->adapter->template_dir = $this->config->root_dir . '/temp/templates/';
$this->adapter->compile_dir = $this->config->root_dir . '/temp/templates_c/';
$this->adapter->config_dir = $this->config->root_dir . '/temp/configs/';
$this->adapter->cache_dir = $this->config->root_dir . '/temp/cache/';
$this->adapter->debugging = $this->config->smarty_debug;
$this->adapter->caching = TRUE;
$this->adapter->cache_lifetime = 30;
$this->adapter->plugins_dir = $this->config->root_dir . '/system/lib/Smarty/libs/plugins';
$this->adapter->compile_check = TRUE;
$this->adapter->force_compile = TRUE;
$this->adapter->register_object('db', $this->db->adapter);
$this->adapter->register_resource('db', array('smarty_resource_db_source', 'smarty_resource_db_timestamp', 'smarty_resource_db_secure', 'smarty_resource_db_trusted'));
$this->adapter->register_resource('data', array('smarty_resource_data_source', 'smarty_resource_data_timestamp', 'smarty_resource_data_secure', 'smarty_resource_data_trusted'));
}
示例3: __construct
public function __construct()
{
// parent::__construct();
config::getInstance();
config::getConfig();
$router = new Router();
$router->explodeUri();
/*
apenas para checagem dos caminhos
//echo '<p>ROUT FILE: '.$routFile.'</p>';
echo '<pre >';
echo '<p>ROTA COMPLETA: '.$this->getRoute().'</p>';
echo '<p>NOME Controller: '.$this->getController().'</p>';
echo '<p>NOME METODO: '.$this->getAction().'</p>';
echo '</pre>';
*/
define('ROUTE', $router->getRoute());
define('CONTROLLER', $router->getController());
define('ACTION', $router->getAction());
$filename = BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . ROUTE . CONTROLLER . '.controller.php';
if (file_exists($filename)) {
require_once $filename;
$_controllerName = CONTROLLER;
$_controller = new $_controllerName();
$action = ACTION;
if (method_exists($_controller, $action)) {
$_controller->{$action}();
} else {
require_once BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . 'error404.controller.php';
$errorController = new error404();
$errorController->index();
}
} else {
require_once BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . 'error404.controller.php';
$errorController = new error404();
$errorController->index();
}
}
示例4: sendRemote
/**
*
* @send a message by remote mail server
*
*/
public function sendRemote()
{
/*** get config values for mail ***/
$config = config::getInstance();
/*** headers ***/
$headers = '';
$this->stream = fsockopen($config->config_values['mail']['smtp_server'], $config->config_values['mail']['smtp_port'], $errno, $errstr, 1);
$res = fgets($this->stream, 256);
if (substr($res, 0, 3) != "220") {
echo $res . 'stream fail<br />';
}
// Introduce ourselves
fputs($this->stream, 'HELO ' . $config->config_values['mail']['smtp_server'] . $this->eol);
$res = fgets($this->stream, 256);
if (substr($res, 0, 3) != "250") {
echo $res . 'helo fail<br />';
}
// Envelope from
fputs($this->stream, 'MAIL FROM: ' . $this->mail_from_email . $this->eol);
$res = fgets($this->stream, 256);
if (substr($res, 0, 3) != "250") {
echo $res . 'mail from fail<br />';
}
// Envelope to
fputs($this->stream, 'RCPT TO: ' . $this->mail_to_email . $this->eol);
$res = fgets($this->stream, 256);
if (substr($res, 0, 3) != "250") {
echo $res . 'to fail<br />';
}
// The message
fputs($this->stream, "DATA" . $this->eol);
$res = fgets($this->stream, 256);
if (substr($res, 0, 3) != "354") {
echo $res . 'data fail';
}
// Send To:, From:, Subject:, other headers, blank line, message, and finish
// with a period on its own line.
fputs($this->stream, 'To: ' . $this->mail_to_name . ' <' . $this->mail_to_email . '>' . $this->eol . 'From: ' . $this->mail_from_name . ' <' . $this->mail_from_email . '>' . $this->eol . 'Subject: ' . $this->mail_subject . $this->eol . $headers . $this->eol . $this->eol . $this->mail_message . $this->eol . '.' . $this->eol);
$res = fgets($this->stream, 256);
if (substr($res, 0, 3) != "250") {
echo $res . 'send fail<br />';
}
// Say bye bye
fputs($this->stream, 'QUIT' . $this->eol);
$res = fgets($this->stream, 256);
if (substr($res, 0, 3) != "221") {
echo $res . 'quit fail<br />';
}
}