无法包含头文件 [英] failed to include header file

查看:112
本文介绍了无法包含头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XAMPP并从在线教程中学习,我只有vedio而不是源代码



这是我的目录结构器



源文件类(文件夹):core.php



源文件 - 电子邮件(文件夹)



source file-inc(文件夹):autoload.php,config.php,index.php



源文件 - 页面(文件夹) :index.php



源文件模板(文件夹):_ header.php;



代码for config.php

I am using XAMPP and learning from online tutorials, i have only vedio not the source code

this is my directory structor

source file-classes(folder):core.php

source file-emails(folder)

source file-inc(folder):autoload.php,config.php, index.php

source file-pages(folder): index.php

source file-template(folder):_header.php;

the code for config.php

<?php

if(!isset($_SESSION)){
    session_start();
}

//site domain name with http

 defined"SITE_URL")

|| define("SITE_URL", "http://".$_SERVER['SERVER_NAME']);



//directory separator
defined("DS")|| define("DS", DIRECTORY_SEPARATOR);


// root pat

defined("ROOT_PATH")|| define("ROOT_PATH", realpath(dirname(__FILE__).DS."..".DS));


//classes folder

defined("CLASSES_DIR")|| define("CLASSES_DIR", "classes");

//defined pages

defined("PAGES_DIR")|| define("PAGES_DIR", "pages");

//module folder

defined("MOD_DIR")|| define("MOD_DIR", "mod");

//inc folder

defined("INC_DIR")|| define("INC_DIR", "inc");

//template folder

defined("TEMPLATE_DIR")|| define("TEMPLATE_DIR", "template");



//email path

defined("EMAILS_PATH")|| define("EMAILS_PATH", ROOT_PATH.DS."emails");

//catalogue images path

defined("CATALOGUE_PATH")|| define("CATALOGUE_PATH", ROOT_PATH.DS."catalogue");

//add all above directories to include path

set_include_path(implode(PATH_SEPARATOR, array(
            realpath(ROOT_PATH.DS.CLASSES_DIR),
    realpath(ROOT_PATH.DS.PAGES_DIR),
    realpath(ROOT_PATH.DS.MOD_DIR),
        realpath(ROOT_PATH.DS.INC_DIR),
        realpath(ROOT_PATH.DS.TEMPLATE_DIR),

        get_include_path()



)));
?>



和autoload.php的代码是


and the code for autoload.php is

<?php

require_once ('config.php');
function __autoload ($class_name){
    $class = explode ("_",$class_name);
    $path=implode ("/",$class).".php";
    require_once ($path);
}

?>




$ inc文件夹中index.php的b $ b代码是



code for the index.php in the inc folder is

<?php
require_once('autoload.php');

$core = new Core();

$core->run();

?>







页面代码(文件夹)index.php是




code for the pages(folder) index.php is

<?php
require_once '_header.php';
?>





当我最后一次运行时索引文件显示错误,

,错误是



when i am running this last index file it show the error,
and the error is

Warning: require_once(_header.php): failed to open stream: No such file or directory in C:\xampp\htdocs\sebastine\pages\index.php on line 5

Fatal error: require_once(): Failed opening required '_header.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\sebastine\pages\index.php on line 5

<请给我一些身体帮助我,我做错了我的猜测是我在配置文件中做了一些错误但我找不到它



谢谢


please some body help me what i am doing wrong my guess is that i am doing some thing wrong in the config files but i can not find it

Thanks

推荐答案

_SESSION)){
session_start();
}

// 网站域名为http

定义 SITE_URL

|| define( SITE_URL < span class =code-string> http://。
_SESSION)){ session_start(); } //site domain name with http defined"SITE_URL") || define("SITE_URL", "http://".


_SERVER [' SERVER_NAME']);



// 目录分隔符
已定义( DS)|| define( DS,DIRECTORY_SEPARATOR);


// root pat

defined( ROOT_PATH)|| define( ROOT_PATH,realpath(dirname(__ FILE __)。DS。 .. .DS));


// classes文件夹

defined( CLASSES_DIR)|| define( CLASSES_DIR < span class =code-string> classes
);

// 已定义的页面

已定义( PAGES_DIR)|| define( PAGES_DIR < span class =code-string> pages);

// 模块文件夹

defined( MOD_DIR)|| define( MOD_DIR < span class =code-string> mod);

// inc文件夹

defined( INC_DIR)|| define( INC_DIR < span class =code-string> inc);

// 模板文件夹

defined( TEMPLATE_DIR)|| define( TEMPLATE_DIR < span class =code-string> template);



// 电子邮件路径

定义( EMAILS_PATH)|| define( EMAILS_PATH,ROOT_PATH.DS。 电子邮件);

// 目录图片路径

已定义( CATALOGUE_PATH)|| define( CATALOGUE_PATH,ROOT_PATH.DS。 catalog);

// 添加以上所有目录以包含路径

set_include_path(implode(PATH_SEPARATOR,数组(
realpath(ROOT_PATH.DS.CLASSES_DIR),
realpath(ROOT_PATH.DS.PAGES_DIR),
realpath(ROOT_PATH.DS.MOD_DIR),
realpath(ROOT_PATH.DS.INC_DIR),
realpath(ROOT_PATH.DS.TEMPLATE_DIR),

get_include_path()



)));
?>
_SERVER['SERVER_NAME']); //directory separator defined("DS")|| define("DS", DIRECTORY_SEPARATOR); // root pat defined("ROOT_PATH")|| define("ROOT_PATH", realpath(dirname(__FILE__).DS."..".DS)); //classes folder defined("CLASSES_DIR")|| define("CLASSES_DIR", "classes"); //defined pages defined("PAGES_DIR")|| define("PAGES_DIR", "pages"); //module folder defined("MOD_DIR")|| define("MOD_DIR", "mod"); //inc folder defined("INC_DIR")|| define("INC_DIR", "inc"); //template folder defined("TEMPLATE_DIR")|| define("TEMPLATE_DIR", "template"); //email path defined("EMAILS_PATH")|| define("EMAILS_PATH", ROOT_PATH.DS."emails"); //catalogue images path defined("CATALOGUE_PATH")|| define("CATALOGUE_PATH", ROOT_PATH.DS."catalogue"); //add all above directories to include path set_include_path(implode(PATH_SEPARATOR, array( realpath(ROOT_PATH.DS.CLASSES_DIR), realpath(ROOT_PATH.DS.PAGES_DIR), realpath(ROOT_PATH.DS.MOD_DIR), realpath(ROOT_PATH.DS.INC_DIR), realpath(ROOT_PATH.DS.TEMPLATE_DIR), get_include_path() ))); ?>



和autoload.php的代码是


and the code for autoload.php is

<?php

require_once ('config.php');
function __autoload (


class_name){
class_name){


这篇关于无法包含头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆