当前位置: 首页>>代码示例>>PHP>>正文


PHP autoload函数代码示例

本文整理汇总了PHP中autoload函数的典型用法代码示例。如果您正苦于以下问题:PHP autoload函数的具体用法?PHP autoload怎么用?PHP autoload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了autoload函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的autoload函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。