本文整理汇总了PHP中autoload函数的典型用法代码示例。如果您正苦于以下问题:PHP autoload函数的具体用法?PHP autoload怎么用?PHP autoload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了autoload函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: autoload
function autoload($dir)
{
$files = scandir($dir);
foreach ($files as $file) {
if ($file == "." || $file == "..") {
continue;
}
$tmp_dir = $dir . DIRECTORY_SEPARATOR . $file;
if (is_dir($tmp_dir)) {
autoload($tmp_dir);
} elseif (is_readable($tmp_dir)) {
require_once $tmp_dir;
}
}
}
开发者ID:fran-diaz,项目名称:itseo,代码行数:15,代码来源:example.php
示例2: autoload
/**
* @param $class
* @param null|string $dir
*/
function autoload($class, $dir = null)
{
if (is_null($dir)) {
$dir = __DIR__ . DIRECTORY_SEPARATOR;
}
$p = explode('\\', $class);
if (count($p) > 1) {
$class = array_pop($p);
$nameSpaceDir = strtolower(implode(DIRECTORY_SEPARATOR, $p));
$dir = $dir . $nameSpaceDir . DIRECTORY_SEPARATOR;
}
foreach (scandir($dir) as $file) {
if (is_dir($dir . $file) && substr($file, 0, 1) !== '.') {
autoload($class, $dir . $file . '/');
}
if (substr($file, 0, 2) !== '._' && preg_match("/.php\$/i", $file)) {
if (str_replace('.php', '', $file) == $class || str_replace('.class.php', '', $file) == $class) {
include $dir . $file;
}
}
}
}
开发者ID:romanitalian,项目名称:singleton,代码行数:26,代码来源:autoload.php
示例3: autoload
function autoload( $class, $dir = null )
{
if ( is_null( $dir ) )
$dir = APPLICATION_PATH . '/FRAMEWORK/PHP/CLASS';
foreach ( scandir( $dir ) as $file )
{
// directory?
if ( is_dir( $dir.'/'.$file ) && substr( $file, 0, 1 ) !== '.' )
{
autoload( $class, $dir.'/'.$file.'/' );
}
// is php & matches class?
if ( preg_match( "/.php$/i" , $file ) && str_replace( '_class.php', '', $file ) == $class)
{
if($_GET['debug'])
print '<!-- PHP: AutoLoad Class: '. $class .' -->' . "\n";
require_once($dir . $file);
}
}
}
开发者ID:supertorti,项目名称:FRAMEWORK,代码行数:23,代码来源:LOADER.PHP
示例4: microtime
<?php
$_SERVER['jemyrazem_start'] = microtime(true);
$_SERVER['backend_start'] = microtime(true);
include __DIR__ . '/../rest/library/backend/include/all.php';
function myshutdown()
{
@Bootstrap::$main->closeConn();
}
mb_internal_encoding('utf8');
autoload([__DIR__ . '/../rest/class', __DIR__ . '/../rest/models', __DIR__ . '/../rest/controllers']);
$config = json_config(__DIR__ . '/../rest/config/application.json');
register_shutdown_function('myshutdown');
$bootstrap = new Bootstrap($config);
$bootstrap->admin = true;
header('Content-type: text/html; charset=utf-8');
开发者ID:podstawski,项目名称:papu,代码行数:16,代码来源:base.php
示例5: session_start
<?php
session_start();
function autoload($class)
{
$classPath = str_replace('\\', '/', $class) . '.php';
$webosFile = realpath(dirname(__DIR__) . '/' . $classPath);
if (file_exists($webosFile)) {
return require $webosFile;
}
}
spl_autoload_register('autoload');
// Loading FlatOS kernel...
autoload('system/kernel/HTTPRequest');
autoload('system/kernel/HTTPResponse');
autoload('system/kernel/RawData');
autoload('system/kernel/Kernel');
autoload('system/kernel/BootLoader');
autoload('system/kernel/JSONQL');
autoload('system/kernel/FS');
autoload('system/kernel/File');
autoload('system/kernel/User');
autoload('system/kernel/UserInterface');
autoload('system/kernel/UserConfig');
// Loading API...
autoload('system/api/Call');
开发者ID:na2axl,项目名称:FlatOS,代码行数:26,代码来源:init.php
示例6: strrpos
<?php
// default values
$dir = __DIR__;
$slashPos = strrpos($dir, '/');
$dir = substr($dir, 0, $slashPos + 1);
$filename = $dir . 'your_project/db/mydb.mwb';
$outDir = $dir . 'your_project/src/AppBundle/Entity/';
$html = "";
// show errors
error_reporting(E_ALL);
ini_set('display_errors', 1);
include 'util.php';
// enable autoloading of classes
$html = autoload($html);
use MwbExporter\Formatter\Doctrine1\Yaml\Formatter as D1Y;
use MwbExporter\Formatter\Doctrine2\Annotation\Formatter as D2A;
use MwbExporter\Formatter\Doctrine2\Yaml\Formatter as D2Y;
use MwbExporter\Formatter\Doctrine2\ZF2InputFilterAnnotation\Formatter as D2Z;
use MwbExporter\Formatter\Propel1\Xml\Formatter as P1X;
use MwbExporter\Formatter\Propel1\Yaml\Formatter as P1Y;
use MwbExporter\Formatter\Sencha\ExtJS3\Formatter as SE3;
use MwbExporter\Formatter\Sencha\ExtJS4\Formatter as SE4;
use MwbExporter\Formatter\Zend\DbTable\Formatter as ZD;
use MwbExporter\Formatter\Zend\RestController\Formatter as ZR;
// setup modes
$mode = array('doctrine1.yaml' => 'doctrine1-yaml', 'doctrine2.annotation' => 'doctrine2-annotation', 'doctrine2.yaml' => 'doctrine2-yaml', 'doctrine2.zf2inputfilter' => 'doctrine2-zf2inputfilterannotation', 'propel.xml' => 'propel1-xml', 'propel.yaml' => 'propel1-yaml', 'sencha.extjs3' => 'sencha-extjs3', 'sencha.extjs4' => 'sencha-extjs4', 'zend.dbtable' => 'zend-dbtable', 'zend.restcontroller' => 'zend-restcontroller');
// IF POST
if (isset($_POST['input']) && isset($_POST['output']) && isset($_POST['mode'])) {
// set inputs
$filename = $_POST['input'];
开发者ID:awallef,项目名称:mysql-workbench-schema-exporter,代码行数:31,代码来源:index.php
示例7: define
<?php
/**
* Drone - Rapid Development Framework for PHP 5.5.0+
*
* @package Drone
* @version 0.2.3
* @copyright 2015 Shay Anderson <http://www.shayanderson.com>
* @license MIT License <http://www.opensource.org/licenses/mit-license.php>
* @link <https://github.com/shayanderson/drone>
*/
//////////////////////////////////////////////////////////////////////////
// Load Drone Framework + run application
//////////////////////////////////////////////////////////////////////////
// set root path
define('PATH_ROOT', __DIR__ . '/');
// include Drone common functions
require_once './_app/lib/Drone/com.php';
// set class autoloading paths
autoload([PATH_ROOT . '_app/lib']);
// include app/Drone bootstrap
require_once './_app/com/app.bootstrap.php';
// run application (execute last)
drone()->run();
开发者ID:NHoeller,项目名称:drone,代码行数:24,代码来源:index.php
示例8: autoload
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* This file is used to autoload the API library
*/
$classes = ['BBM\\Server\\Config\\SysConfig', 'BBM\\Server\\Connect', 'BBM\\Server\\Exception', 'BBM\\Server\\Request', 'BBM\\Download', 'BBM\\Catalog', 'BBM\\Purchase'];
/**
* Used to load the class passed by parameter.
* @param $className
*/
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
foreach ($classes as $class) {
autoload($class);
}
开发者ID:bibliomundi,项目名称:client-side-api,代码行数:31,代码来源:autoload.php
示例9: autoload
<?php
autoload('app\\', ROOT_PATH . 'application/src/');
autoload('framework\\', ROOT_PATH . 'framework/');
function autoload($prefix, $baseDir)
{
spl_autoload_register(function ($class) use($prefix, $baseDir) {
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// get the relative class name
$relativeClass = substr($class, $len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});
}
开发者ID:haohong725,项目名称:xmvc,代码行数:25,代码来源:init_autoload.php
示例10: autoload
/**
* Recursively loads all php files in all subdirectories of the given path
*
* @param $directory
*/
function autoload($directory)
{
// Get a listing of the current directory
$scanned_dir = scandir($directory);
if (empty($scanned_dir)) {
return;
}
// Ignore these items from scandir
$ignore = array('.', '..');
// Remove the ignored items
$scanned_dir = array_diff($scanned_dir, $ignore);
foreach ($scanned_dir as $item) {
$filename = $directory . '/' . $item;
$real_path = realpath($filename);
if (false === $real_path) {
continue;
}
$filetype = filetype($real_path);
if (empty($filetype)) {
continue;
}
// If it's a directory then recursively load it
if ('dir' === $filetype) {
autoload($real_path);
} else {
if ('file' === $filetype) {
// Don't allow files that have been uploaded
if (is_uploaded_file($real_path)) {
continue;
}
// Don't load any files that are not the proper mime type
if ('text/x-php' !== mime_content_type($real_path)) {
continue;
}
$filesize = filesize($real_path);
// Don't include empty or negative sized files
if ($filesize <= 0) {
continue;
}
// Don't include files that are greater than 100kb
if ($filesize > 100000) {
continue;
}
$pathinfo = pathinfo($real_path);
// An empty filename wouldn't be a good idea
if (empty($pathinfo['filename'])) {
continue;
}
// Sorry, need an extension
if (empty($pathinfo['extension'])) {
continue;
}
// Actually, we want just a PHP extension!
if ('php' !== $pathinfo['extension']) {
continue;
}
// Only for files that really exist
if (true !== file_exists($real_path)) {
continue;
}
if (true !== is_readable($real_path)) {
continue;
}
require_once $real_path;
}
}
}
}
开发者ID:aaronholbrook,项目名称:autoload,代码行数:73,代码来源:autoload.php
示例11: autoload
include_once 'bootstrap.custom.php';
}
/**
* Include this file to bootstrap the library. Registers an SPL autoloader to
* automatically detect and load library class files at runtime.
*
* @copyright Copyright (c) 2011, Box UK
* @license http://opensource.org/licenses/mit-license.php MIT License and http://www.gnu.org/licenses/gpl.html GPL license
* @link https://github.com/boxuk/describr
* @since 1.0.0
*/
/**
* @param string $rootDir e.g. /opt/BoxUK/describr/lib
* @param string $pathToPHPReaderLibrary e.g. /opt/vendor/php-reader/1.8.1/src
*/
function autoload($rootDir, $pathToPHPReaderLibrary)
{
spl_autoload_register(function ($className) use($rootDir, $pathToPHPReaderLibrary) {
$file = sprintf('%s/%s.php', $rootDir, str_replace('\\', '/', $className));
if (file_exists($file)) {
require $file;
} else {
$file = sprintf('%s/%s.php', $pathToPHPReaderLibrary, str_replace('_', '/', $className));
if (file_exists($file)) {
require $file;
}
}
});
}
autoload(__DIR__, $describr_pathToPHPReaderLibrary);
开发者ID:boxuk,项目名称:describr,代码行数:30,代码来源:bootstrap.php
示例12: autoload
<?php
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
autoload('\\Simphplist\\Simphplist\\Request');
use Simphplist\Simphplist\Request;
echo Request::get('test', 'use ?test=string');
开发者ID:pombredanne,项目名称:simphplist,代码行数:18,代码来源:index.php
示例13: ini_set
<?php
ini_set('display_errors', 'On');
ini_set('error_reporting', -1);
require_once __DIR__ . '/../vendor/autoload.php';
function autoload($rootDir)
{
spl_autoload_register(function ($className) use($rootDir) {
$file = sprintf('%s/%s.php', $rootDir, str_replace('\\', '/', $className));
if (file_exists($file)) {
require $file;
}
});
}
autoload('/usr/share/php');
autoload(__DIR__ . '/');
autoload(__DIR__ . '/Url');
autoload(__DIR__ . '/NormalisedUrl');
开发者ID:webignition,项目名称:url,代码行数:18,代码来源:bootstrap.php
示例14: define
along with this program. If not, see <http://www.gnu.org/licenses/>.
Modified version of class done by David Marco Martinez
*/
// Permision to set for uploaded .torrent files (don't touch unless you know)
define('PERM_TORRENTS', 0777);
// Don't touch any of the data below unless you know what you are doing
define('DIR_LANG', 'wt/lang/');
define('DIR_TPL', 'wt/tpl/');
define('DIR_TPL_COMPILE', 'tpl_c/');
define('DIR_TPL_HTML', 'wt/html/');
define('DIR_BACKUP', 'backup/');
define('DIR_UPLOAD', 'torrents/');
define('DIR_CSS', 'wt/css/');
define('DIR_JS', 'wt/js/');
define('DIR_IMG', 'wt/img/');
define('SRC_INDEX', 'index.php');
define('TITLE', 'wTorrent');
define('META_TITLE', 'rTorrent web interface');
define('META_KEYWORDS', 'rtorrent xmlrpc interface php web html');
define('META_DESCRIPTION', 'rtorrent web inrface using xmlrpc');
// Minimum execution time (due to scriptaculous effects duration)
define('MIN_TIME', 0.6);
define('SCRAMBLE', false);
define('APP', 'wTorrent');
// General libs
require_once 'lib/inc/includes.inc.php';
// Autoloading of classes
autoload('lib/cls/', 'cls/', 'wt/cls/');
// UNIX path definition
ini_set('include_path', DIR_EXEC);
开发者ID:santa01,项目名称:wtorrent,代码行数:31,代码来源:system.conf.php
示例15: __autoload
function __autoload($class)
{
return autoload($class);
}
开发者ID:nomagame,项目名称:ZiFeiYu-Management-System,代码行数:4,代码来源:common.php
示例16: submit_order
/**
* 提交订单
*/
public function submit_order()
{
/* 检查购物车中是否有商品 */
if (count($_SESSION['wholesale_goods']) == 0) {
show_message(L('no_goods_in_cart'));
}
/* 检查备注信息 */
if (empty($_POST['remark'])) {
show_message(L('ws_remark'));
}
/* 计算商品总额 */
$goods_amount = 0;
foreach ($_SESSION['wholesale_goods'] as $goods) {
$goods_amount += $goods['subtotal'];
}
$order = array('postscript' => htmlspecialchars($_POST['remark']), 'user_id' => $_SESSION['user_id'], 'add_time' => gmtime(), 'order_status' => OS_UNCONFIRMED, 'shipping_status' => SS_UNSHIPPED, 'pay_status' => PS_UNPAYED, 'goods_amount' => $goods_amount, 'order_amount' => $goods_amount);
/* 插入订单表 */
$error_no = 0;
do {
$order['order_sn'] = get_order_sn();
//获取新订单号
$this->model->table('order_info')->data($order)->insert();
$error_no = $this->model->errno();
if ($error_no > 0 && $error_no != 1062) {
die($this->model->errorMsg());
}
} while ($error_no == 1062);
//如果是订单号重复则重新提交数据
$new_order_id = $this->model->insert_id();
$order['order_id'] = $new_order_id;
/* 插入订单商品 */
foreach ($_SESSION['wholesale_goods'] as $goods) {
//如果存在货品
$product_id = 0;
if (!empty($goods['goods_attr_id'])) {
$goods_attr_id = array();
foreach ($goods['goods_attr_id'] as $value) {
$goods_attr_id[$value['attr_id']] = $value['attr_val_id'];
}
ksort($goods_attr_id);
$goods_attr = implode('|', $goods_attr_id);
$res = $this->model->table('products')->field('product_id')->where("goods_attr = '{$goods_attr}' AND goods_id = '" . $goods['goods_id'] . "'")->find();
$product_id = $res['product_id'];
}
$sql = "INSERT INTO " . $this->model->pre . "order_goods( " . "order_id, goods_id, goods_name, goods_sn, product_id, goods_number, market_price, " . "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift) " . " SELECT '{$new_order_id}', goods_id, goods_name, goods_sn, '{$product_id}','{$goods['goods_number']}', market_price, " . "'{$goods['goods_price']}', '{$goods['goods_attr']}', is_real, extension_code, 0, 0 " . " FROM " . $this->model->pre . "goods WHERE goods_id = '{$goods['goods_id']}'";
$this->model->query($sql);
}
/* 给商家发邮件 */
if (C('service_email') != '') {
$tpl = get_mail_template('remind_of_new_order');
$this->assign('order', $order);
$this->assign('shop_name', C('shop_name'));
$this->assign('send_date', date(C('time_format')));
$content = ECTouch::view()->fetch('str:' . $tpl['template_content']);
send_mail(C('shop_name'), C('service_email'), $tpl['template_subject'], $content, $tpl['is_html']);
}
/* 如果需要,发短信 */
if (C('sms_order_placed') == '1' && C('sms_shop_mobile') != '') {
autoload('EcsSms');
$sms = new EcsSms();
$msg = L('order_placed_sms');
$sms->send(C('sms_shop_mobile'), sprintf($msg, $order['consignee'], $order['mobile']), '', 13, 1);
}
/* 清空购物车 */
unset($_SESSION['wholesale_goods']);
/* 提示 */
show_message(sprintf(L('ws_order_submitted'), $order['order_sn']), L('ws_return_home'), url('index'));
}
开发者ID:m7720647,项目名称:demo,代码行数:71,代码来源:WholesaleController.class.php
示例17: microtime
<?php
$_SERVER['backend_start'] = microtime(true);
include __DIR__ . '/backend/include/all.php';
autoload([__DIR__ . '/classes', __DIR__ . '/controllers']);
$config = json_config(__DIR__ . '/config/application.json');
$bootstrap = new Bootstrap($config);
$root = $bootstrap->getRoot();
$uri = $_SERVER['REQUEST_URI'];
if ($pos = strpos($uri, '?')) {
$uri = substr($uri, 0, $pos);
}
$uri = substr($uri, strlen($root));
$q = urldecode(trim(str_replace(['-', '/', "'"], ' ', $uri)));
$google_part = '';
$description = $q ? str_replace('{q}', $q, $bootstrap->getConfig('page.description')) : $bootstrap->getConfig('page.description0');
if (isset($_GET['_google']) || isset($_SERVER['HTTP_USER_AGENT']) && strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'google')) {
if ($q) {
$google_part = '<h1>' . $q . '</h1>' . "\n";
$template = new templateController();
$template->init();
$holidays = new holidaysController(0, ['q' => $q]);
$holidays->init();
$tmpl = $template->get(false);
$tmpl = preg_replace('~\\[if:[^\\]]+\\]~', '', $tmpl);
$tmpl = preg_replace('~\\[endif:[^\\]]+\\]~', '', $tmpl);
$tmpl = preg_replace('~\\[loop:[^\\]]+\\]~', '', $tmpl);
$tmpl = preg_replace('~\\[endloop:[^\\]]+\\]~', '', $tmpl);
$tmpl = str_replace('style="display:none"', '', $tmpl);
$result = $holidays->get(10);
foreach ($result['data'] as $rec) {
开发者ID:WebKameleon,项目名称:wakacje,代码行数:31,代码来源:index.php
示例18: autoload
<?php
/**
* Includes all libaries related to plugin loading
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
*
* @author Christoph Hochstrasser <[email protected]>
* @copyright Copyright (c) 2010 Christoph Hochstrasser
* @license MIT License
*/
autoload('Core\\Plugin\\Exception', __DIR__ . '/Plugin/Exception.php');
autoload('Core\\Plugin\\ExceptionStack', __DIR__ . '/Plugin/ExceptionStack.php');
autoload('Core\\Plugin\\Controller', __DIR__ . '/Plugin/Controller.php');
autoload('Core\\Plugin\\AbstractPlugin', __DIR__ . '/Plugin/AbstractPlugin.php');
require_once 'Plugin/Plugin.php';
require_once 'Plugin/Loader.php';
require_once 'Plugin/Environment.php';
require_once 'Plugin/StandardLoader.php';
开发者ID:CHH,项目名称:Simple-CMS,代码行数:20,代码来源:Plugin.php
示例19: ini_set
<?php
ini_set('display_errors', 'On');
require_once __DIR__ . '/../vendor/autoload.php';
function autoload($rootDir)
{
spl_autoload_register(function ($className) use($rootDir) {
$file = sprintf('%s/%s.php', $rootDir, str_replace('\\', '/', $className));
if (file_exists($file)) {
require $file;
}
});
}
autoload('/usr/share/php');
autoload(__DIR__ . '/');
开发者ID:webignition,项目名称:jslint-directive-string-parser,代码行数:15,代码来源:bootstrap.php
示例20: drop_consignee
/**
* 删除收货人信息
*/
public function drop_consignee() {
autoload('lib_transaction');
$consignee_id = intval($_GET['id']);
if (model('Users')->drop_consignee($consignee_id)) {
ecs_header("Location: " . url('flow/consignee_list') . "\n");
exit;
} else {
show_message(L('not_fount_consignee'));
}
}
开发者ID:sayi21cn,项目名称:ecshopAndEctouch,代码行数:15,代码来源:FlowController.class.php
注:本文中的autoload函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论