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


PHP spl_autoload函数代码示例

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


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

示例1: helper

 public function helper($class)
 {
     $class = preg_replace('/_helper$/ui', '', $class);
     set_include_path(get_include_path() . PATH_SEPARATOR . '/helper/');
     spl_autoload_extensions('.helper.php');
     spl_autoload($class);
 }
开发者ID:softdevelop,项目名称:phpOOP_SOFTDevelop,代码行数:7,代码来源:autoloader.php

示例2: zroneClassLoader

/**
 * 自动加载
 *
 * @param $className
 */
function zroneClassLoader($className)
{
    $path = array(str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Vendor/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "FrameWork/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Application/"));
    if (isset($path) && is_array($path)) {
        $Iterator = new ArrayIterator($path);
        $Iterator->rewind();
        $pathString = "";
        while ($Iterator->valid()) {
            $pathString .= $Iterator->current() . ";";
            if ($Iterator->key() == count($path) - 1) {
                $pathString = rtrim($pathString, ";");
            }
            $Iterator->next();
        }
        set_include_path($pathString);
        spl_autoload_extensions(".php, .class.php");
        spl_autoload($className);
    } else {
        try {
            throw new Exception("<code style='color: red; font-size: 22px; display: block; text-align: center; height: 40px; line-height: 40px;'>I'm sorry, my dear! The FrameWork is Wrong……😫</code>");
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
}
开发者ID:zrone,项目名称:apiDocument,代码行数:30,代码来源:zroneFrameWork.php

示例3: helper

 public function helper($class)
 {
     $class = $this->trim_namespace($class);
     set_include_path($this->registry->appDir . '/helpers/');
     spl_autoload_extensions('.help.php');
     spl_autoload($class);
 }
开发者ID:arunprasathb,项目名称:KMF-MVC,代码行数:7,代码来源:Autoloader.php

示例4: load

 public static function load($class_name)
 {
     $segments = explode('\\', $class_name);
     $class = array_pop($segments);
     $file_name = implode('\\', $segments);
     //  print($file_name);
     spl_autoload($file_name, '.php');
 }
开发者ID:lehaBay,项目名称:view-metter,代码行数:8,代码来源:Autoload.php

示例5: autoload

/**
 * Load the class specified 
 * @param	string		Class to load
 */
function autoload($className)
{
    /* We're using the built-in autoloader as it's faster than a PHP implementation.
     * Replace underscores with slashes to use a directory structure (FeedSources_Twitter -> includes/FeedSources/Twitter.php)
     */
    $filename = strtolower(str_replace('_', '/', $className));
    return spl_autoload($filename);
}
开发者ID:paravoid,项目名称:pmacct-frontend,代码行数:12,代码来源:core.php

示例6: plugin_autoloader

function plugin_autoloader($class)
{
    $file = dirname(__FILE__) . '/../../src/class-' . str_replace('_', '-', strtolower($class)) . '.php';
    if (file_exists($file)) {
        include $file;
    } else {
        spl_autoload($class);
    }
}
开发者ID:gasbriones,项目名称:bacare,代码行数:9,代码来源:TinyTestCase.php

示例7: buffered_autoloader

 function buffered_autoloader($c)
 {
     try {
         spl_autoload($c);
     } catch (Exception $e) {
         $message = $e->getMessage();
         return $message;
     }
 }
开发者ID:Jursdotme,项目名称:MailChimp-Widget,代码行数:9,代码来源:mailchimp-widget.php

示例8: register

 public static function register($path)
 {
     if (function_exists('__autoload')) {
         spl_autoload_register('__autoload');
     }
     spl_autoload_register(function ($class) use(&$path) {
         set_include_path($path);
         spl_autoload($class);
     });
 }
开发者ID:Jathon-yang,项目名称:PhpLibrary,代码行数:10,代码来源:Autoload.php

示例9: base_class

 private function base_class($className)
 {
     $path = array();
     $pathDir = array();
     $path = explode('_', $className);
     $arrCount = count($path) - 1;
     $pathDir = implode("/", array_slice($path, 0, $arrCount));
     set_include_path(ROOT_PATH . "includes/" . $pathDir);
     spl_autoload_extensions('.class.php');
     spl_autoload($path[$arrCount]);
 }
开发者ID:sdgdsffdsfff,项目名称:dbroute,代码行数:11,代码来源:autoload.class.php

示例10: registerAutoload

 /**
  * Register autoloading for classes
  */
 public function registerAutoload()
 {
     // firstly include vendor autoload
     include BASEDIR . 'vendor' . DS . 'autoload.php';
     // Classes from APPDIR/classes/ directory
     set_include_path(get_include_path() . PATH_SEPARATOR . APPDIR . 'classes' . DS);
     // all classes from the APPDIR.'classes' directory must have extension '.class.php'
     spl_autoload_extensions('.class.php');
     // all class files must lowercase name to avoid problems with case sensitivity
     spl_autoload_register(function ($class_name) {
         spl_autoload(strtolower($class_name));
     });
 }
开发者ID:spirlici,项目名称:spcms,代码行数:16,代码来源:app.php

示例11: load

	private static function load($className) {
		foreach(self::$_sources as $path) {
			$directories = self::diretoryToArray("./", true);
			foreach($directories as $directory) {
				if(file_exists($path.'/'.$directory.'/'.$className.'.php')) {
					set_include_path($path.'/'.$directory);
					spl_autoload($className);
				}
			}
		}
		
		throw new FileNotFoundException();
	}
开发者ID:Grinderofl,项目名称:PhpMvc,代码行数:13,代码来源:Autoloader.php

示例12: define

<?php

define('ROOT', $_SERVER['DOCUMENT_ROOT']);
define('LIB', ROOT . '/engine/lib');
define('MODEL_ROOT', ROOT . '/engine/models/');
spl_autoload_extensions('.php');
set_include_path(MODEL_ROOT);
spl_autoload_register(function ($class) {
    spl_autoload($class);
});
开发者ID:k-integer,项目名称:2cars,代码行数:10,代码来源:main.php

示例13: spl_autoload

<?php

spl_autoload("Spec");
spl_autoload("Helper");
class AClass extends Automobile
{
    const className = "A-Class";
    const classPrice = 16000;
    const airCondType = "cond";
    const airbagSlug = "airbag";
    const airBagNumber = 6;
    public function __construct()
    {
        parent::__construct(self::className, self::classPrice);
        $this->equipCar();
    }
    public function equipCar()
    {
        $specs = SpecStorage::getCommonSpecifications();
        array_push($specs, SpecStorage::getSpecification(self::airCondType));
        array_push($specs, SpecStorage::getSpecification(self::airbagSlug, self::airBagNumber));
        $this->assignDefaultSpecs($specs);
    }
}
开发者ID:sscerbatiuc,项目名称:PentaTask,代码行数:24,代码来源:AClass.php

示例14: autoload

 /**
  * Autoload function for TYPO3.
  *
  * This method looks up class names in the registry
  * (which contains extensions and core files)
  *
  * @param string $className Class name
  * @return void
  */
 public static function autoload($className)
 {
     $className = ltrim($className, '\\');
     $realClassName = static::getClassNameForAlias($className);
     $aliasClassName = static::getAliasForClassName($className);
     $hasAliasClassName = $aliasClassName !== $className;
     $lookUpClassName = ($hasRealClassName = $className !== $realClassName) ? $realClassName : $className;
     // Use core and extension registry
     $classPath = static::getClassPathByRegistryLookup($lookUpClassName);
     if ($classPath && !class_exists($realClassName, FALSE)) {
         // Include the required file that holds the class
         // Handing over the class name here is only done for the
         // compatibility class loader so that it can skip class names
         // which do not require rewriting. We can remove this bad
         // code smell once we can get rid of the compatibility class loader.
         static::requireClassFileOnce($classPath, $className);
         try {
             // Regular expression for a valid classname taken from
             // http://www.php.net/manual/en/language.oop5.basic.php
             if (preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $className)) {
                 spl_autoload($className);
             }
         } catch (\LogicException $exception) {
         }
     }
     if ($hasRealClassName && !class_exists($className, FALSE)) {
         class_alias($realClassName, $className);
     }
     if ($hasAliasClassName && !class_exists($aliasClassName, FALSE)) {
         class_alias($className, $aliasClassName);
     }
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:41,代码来源:ClassLoader.php

示例15: views

 public function views($class)
 {
     set_include_path(get_include_path() . PATH_SEPARATOR . 'views/');
     spl_autoload_extensions('.php');
     spl_autoload($class);
 }
开发者ID:GonikDaniel,项目名称:php_study_project,代码行数:6,代码来源:autoloader.php


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