Home > Backend Development > PHP Tutorial > autoload加载

autoload加载

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:26:34
Original
1001 people have browsed it

后台添加商品分类的时候出现 Fatal error: Cannot redeclare __autoload() (previously declared in F:\wamp\www\ship\include\init.php:31) in F:\wamp\www\ship\include\init.php on line 39
init.php
define('ROOT',str_replace('\\','/',dirname(dirname(__FILE__))) . '/');
define('DEBUG',true);


require(ROOT . 'include/lib_base.php');

function __autoload($class) {
    if(strtolower(substr($class,-5)) == 'model') {
        require(ROOT . 'Model/' . $class . '.class.php');
    } else if(strtolower(substr($class,-4)) == 'tool') {
        require(ROOT . 'tool/' . $class . '.class.php');
    } else {
        require(ROOT . 'include/' . $class . '.class.php');
    }
}


$_GET = _addslashes($_GET);
$_POST = _addslashes($_POST);
$_COOKIE = _addslashes($_COOKIE);




session_start();

if(defined('DEBUG')) {
    error_reporting(E_ALL);
} else {
    error_reporting(0);
}


回复讨论(解决方案)

看错误信息呢, 函数重定义了, 看看是不是在其他地方还定义了这个函数。。

重复定义__autoload,在这个文件里面看看F:\wamp\www\ship\include\init.php

看错误信息呢, 函数重定义了, 看看是不是在其他地方还定义了这个函数。。



我在model类里面多加了个require('init.php') 所以重复了 谢谢

重复定义__autoload,在这个文件里面看看F:\wamp\www\ship\include\init.php



谢谢
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template