本文整理汇总了PHP中module::import方法的典型用法代码示例。如果您正苦于以下问题:PHP module::import方法的具体用法?PHP module::import怎么用?PHP module::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module
的用法示例。
在下文中一共展示了module::import方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
$config = module::import('config');
$dbconfig = $config('db');
//var_dump($dbconfig);
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $dbconfig->encoding . ';');
$db = new PDO('mysql:dbname=' . $dbconfig->dbname . ';host=' . $dbconfig->host . (!empty($dbconfig->port) ? ';port=' . $dbconfig->port : ''), $dbconfig->username, $dbconfig->password, $options);
//$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
//$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $db;
示例2:
<?php
static $auth;
if (!empty($auth)) {
return $auth;
}
return module::import('auth-basic');
示例3: function
<?php
return function ($key = 'application') {
$storage = module::import('storage-phpfile');
$storage = $storage(_APP_ROOT . '/app/config');
return $storage($key);
};
示例4:
<?php
module::import('auth-token')->requireTools();
$sname = !empty($_GET['n']) ? $_GET['n'] : $_POST['name'];
//...
示例5: isset
<?php
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
$auth = module::import('auth');
// example for add auth
$auth->requireAdmin();
// code of page
var_dump($auth->user);
if (empty($auth->user)) {
$auth->login();
var_dump('after login: ', $auth->user);
} else {
$roles = $auth->user['roles'];
var_dump('is admin: ', isset($roles['admin']));
}
示例6:
<?php
$_GET['template'] = 'examplesite';
require 'vendor/autoload.php';
$app = module::import('app');
//$event->trigger('page_start', $nothing);
include $app->template . '/header.php';
//dump($app);
include $app->current_path . '/_data/layout.php';
include $app->template . '/footer.php';
//$event->trigger('page_end', $nothing);
示例7: var_dump
<?php
require '../vendor/autoload.php';
$db = module::import('db');
var_dump($db);
$sql = module::import('sql');
list($SELECT, $INSERT, $UPDATE, $INSERT_UPDATE, $DELETE) = $sql([$db, 'quote']);
$row = ['name' => 'tester1', 'email' => 'email@example.org', 'id' => 5];
var_dump($INSERT('table1', $row), $UPDATE('table1', $row), $INSERT_UPDATE('table1', $row), $SELECT('table1', $row), $DELETE('table1', $row));
示例8:
<?php
// check is admin
if (!isset(module::import('auth')->user['roles']['admin'])) {
return;
}
?>
<script src="/vendor/assets/site-editor/init.js"></script>