本文整理汇总了PHP中Conf::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Conf::init方法的具体用法?PHP Conf::init怎么用?PHP Conf::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conf
的用法示例。
在下文中一共展示了Conf::init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* 部分功能初始化
*/
public static function init()
{
//引入公共方法
require __BT__ . '/common/common.php';
if (defined("__APP__")) {
$file = __APP__ . '/common/common.php';
if (is_file($file)) {
require $file;
}
$config = __APP__ . '/library/Config.php';
if (is_file($config)) {
$conf = (include $config);
//初始化conf
Conf::init($conf);
}
}
//定义常量.
define('PHP_CLI', php_sapi_name());
define('NOW_TIME', $_SERVER['REQUEST_TIME']);
if (PHP_CLI != 'cli') {
define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ? true : false);
}
}
示例2: run
public function run($config)
{
Conf::init($config);
//设置app路由
if ($_SERVER['REQUEST_URI'] != "/") {
$server_request_uri = parse_url($_SERVER['REQUEST_URI']);
$domainInfo = Router::init()->parseDomain($server_request_uri['path'], Conf::init()->getConf("ROUTER"), Conf::init()->getConf("ROUTER")['default']);
Conf::init()->setAppInfo($domainInfo);
//注册应用地址
}
Autoloader::register(Conf::init()->getAppPath());
//获取路由表
$routers = Conf::init()->getRouter();
//解析url路径
$actArr = array();
if ($_SERVER['REQUEST_URI'] === "/") {
$actArr = Router::init()->getDefaultAct();
} else {
$server_request_uri = parse_url($_SERVER['REQUEST_URI']);
$actArr = Router::init()->parse($server_request_uri['path'], $routers);
}
Router::init()->load(Conf::init()->getAppPath(), $actArr);
}
示例3: define
define('ROOT_DIR', dirname(dirname(__FILE__)));
/**
* 全局配置类
*/
class Conf
{
static $rootDir;
static $scriptDir;
static function init()
{
self::$rootDir = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
$scriptDir = str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']);
self::$scriptDir = substr($scriptDir, 0, strrpos($scriptDir, '/'));
}
}
Conf::init();
require_once ROOT_DIR . '/common/Util.php';
require_once ROOT_DIR . '/common/Service.php';
/*
Service 组件在每个页面里面的调用方法
$service = new Service(array(
'tplPath' => 'zhuanti/index',
// json文件数组配置,会依次读取json文件中的变量,然后塞到smarty的templateVars
'json' => array(
'../common/data/header.json',
'./data'
),
// 或者采用hash数组配置,会把json对象赋值给`key`,然后塞到smarty的templateVars
'json' => array(
'header' => '../common/data/header.json',
'data' => './data'
示例4: define
<?php
//+---------------------------------------------------------------------------------------------------------------------------------+
// /
// Copyright (c) 2012 Yahoo! Inc. All rights reserved. /
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this /
// file except in compliance with the License. You may obtain a copy of the License at /
// /
// http://www.apache.org/licenses/LICENSE-2.0 /
// /
// Unless required by applicable law or agreed to in writing, software distributed under /
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF /
// ANY KIND, either express or implied. See the License for the specific language governing /
// permissions and limitations under the License. See accompanying LICENSE file. /
// /
// $Author:shawcs@yahoo-inc.com $Date: 30-Jan-2012 /
// /
//+---------------------------------------------------------------------------------------------------------------------------------+
define('OPS_APP_PRIVATE_DIR', dirname(__FILE__));
require_once 'assist/common/init.php';
require_once 'assist/include.inc';
// initialize config files
Conf::init('conf/calendar_database.ini', 'db');