本文整理汇总了PHP中base::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP base::getInstance方法的具体用法?PHP base::getInstance怎么用?PHP base::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base
的用法示例。
在下文中一共展示了base::getInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: link_tag
function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
{
$OB = base::getInstance();
$link = '<link ';
if (is_array($href)) {
foreach ($href as $k => $v) {
if ($k == 'href' and strpos($v, '://') === FALSE) {
if ($index_page === TRUE) {
$link .= ' href="' . $OB->config->site_url($v) . '" ';
} else {
$link .= ' href="' . $OB->config->slash_item('base_url') . $v . '" ';
}
} else {
$link .= "{$k}=\"{$v}\" ";
}
}
$link .= "/>";
} else {
if (strpos($href, '://') !== FALSE) {
$link .= ' href="' . $href . '" ';
} elseif ($index_page === TRUE) {
$link .= ' href="' . $OB->config->site_url($href) . '" ';
} else {
$link .= ' href="' . $OB->config->slash_item('base_url') . $href . '" ';
}
$link .= 'rel="' . $rel . '" type="' . $type . '" ';
if ($media != '') {
$link .= 'media="' . $media . '" ';
}
if ($title != '') {
$link .= 'title="' . $title . '" ';
}
$link .= '/>';
}
return $link;
}
示例2: this
function this()
{
return base::getInstance();
}
示例3: _assign_db_objects
public function _assign_db_objects()
{
foreach (base::$databases as $key) {
$this->{$key} =& base::getInstance()->{$key};
}
}
示例4: _write_cache
public function _write_cache($output)
{
$OB = base::getInstance();
//$path = common::config_item('cache_path', 'cache');
$cache_path = APP . 'cache' . DS;
//= ($path == '') ? APP.'system'.DS.'cache'.DS : $path;
if (!is_dir($cache_path) or !common::is_really_writable($cache_path)) {
throw new Exception('Unable to write cache file: ' . $cache_path);
return;
}
$uri = $OB->config->item('base_url') . $OB->config->item('index_page') . $OB->uri->uri_string();
$cache_path .= md5($uri);
if (!($fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))) {
throw new Exception('Unable to write cache file: ' . $cache_path);
return;
}
$expire = time() + $this->cache_expiration * 60;
if (flock($fp, LOCK_EX)) {
fwrite($fp, $expire . 'TS--->' . $output);
flock($fp, LOCK_UN);
} else {
throw new Exception('Unable to secure a file lock for file at: ' . $cache_path);
return;
}
fclose($fp);
@chmod($cache_path, DIR_WRITE_MODE);
//log_message('debug', "Cache file written: ".$cache_path);
}
示例5: database
public static function database($db_name = 'db')
{
$db_var = $db_name;
$obj = base::getInstance();
if (isset($obj->{$db_var}) and is_object($obj->{$db_var})) {
return;
}
require SYS . 'database' . DS . 'db_factory' . PHP_EXT;
$obj->{$db_var} = db_factory::callDB($db_name);
base::$databases[$db_var] = $db_var;
if (count(base::$models) >= 0) {
foreach (base::$models as $model_name) {
$obj->{$model_name}->{$db_var} =& $obj->{$db_var};
}
}
}