當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。