插件页面上的代码,我尝试获取构造函数中的文件------------------------------ -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- --------------------------------------------:Wordpress插件开发 - 如何从PHP OOP中的文件夹自动加载类?
<?php
/*
Plugin Page Code
*/
if(!class_exists('Tooo')) {
final class Tooo {
public function __construct()
{
require_once(plugin_dir_path(__FILE__) . 'admin/classes/class-file-loader.php');
}
}
}
$obj2 = new Tooo;
这是我的加载页面代码:
<?php
/**
* Autoloads testc classes using WordPress convention.
*
* @author testc Webdesign
*/
class testc_Loader
{
/**
* Registers testc Loader as an SPL autoloader.
*
* @param boolean $prepend
*/
public static function register($prepend = false)
{
if (version_compare(phpversion(), '5.3.0', '>=')) {
spl_autoload_register(array(new self, 'autoload'), true, $prepend);
} else {
spl_autoload_register(array(new self, 'autoload'));
}
}
/**
* Handles autoloading of testc classes.
*
* @param string $class
*/
public static function autoload($class)
{
if (is_file($class = plugin_dir_path(__FILE__) .'admin/classes/'.strtolower(str_replace(array('_', "\0"), array('-', ''), $class).'.php'))) {
include($class);
}
}
}
testc_Loader::register();
所以弄得不明白为什么它不包括。