Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 标题及;页脚未显示_Php_Templates_Php Include - Fatal编程技术网

Php 标题及;页脚未显示

Php 标题及;页脚未显示,php,templates,php-include,Php,Templates,Php Include,因此,在一点帮助下,我就能够在本地启动并运行我的第一个mvc框架。现在我已经把它放在服务器上了,我一点运气都没有。我相信这是一个配置问题,但我似乎无法理解 为什么直接转到远程路径时没有显示任何内容?即: 这不起作用: 除非我将'URI'常量直接设置为'/register',这是它在localhost上运行时的输出,如下面的注释所示 这可以工作,但不是我想要的&不包括页眉+页脚: config.php <?php include_once 'load.php';

因此,在一点帮助下,我就能够在本地启动并运行我的第一个mvc框架。现在我已经把它放在服务器上了,我一点运气都没有。我相信这是一个配置问题,但我似乎无法理解

为什么直接转到远程路径时没有显示任何内容?即:

  • 这不起作用:
    • 除非我将'URI'常量直接设置为'/register',这是它在localhost上运行时的输出,如下面的注释所示
  • 这可以工作,但不是我想要的&不包括页眉+页脚:

config.php

<?php

    include_once 'load.php';

    // Local
    // define ('URL_ROOT', 'http://localhost/');

    // Remote
    define ('URL_ROOT', 'http://tomcat.cit.ipui.edu/alecory/Spring-2014/Assignment%202/');

    // define ('URI', $_SERVER['REQUEST_URI']);
    // Outputs for:
    //    Local  = /register                                        
    //    Remote = /alecory/Spring-2014/CIT-31300/Assignment%202/views/register.php
    define('URI', '/register'); // <= this is where I could set it myself and 
                                    # it would reroute the URL from
                                    # /Assignment%202/views/register.php   To         
                                    # /Assignment%202/ 
                                    # (only showing /Assignment%202/ in the URL)

    define ('DOC_ROOT', $_SERVER['DOCUMENT_ROOT']);
    //    Local  = /Applications/MAMP/htdocs/CIT-31300/Assignment 2
    //    Remote = /var/www/                       

?>
<?php 

/**
* Controller
* 
* Description: Basically tells the system what to do and in what order
*/
class Controller
{
    public $load;
    public $model;

    function __construct()
    {
        // Make
        $this->load  = new Load();
        $this->model = new Model();

        // Set the $page = current view/page
        $page = ltrim(URI, '/');

        // Set default page to index
        if (empty($page))
        {
            $page = 'index';
        }

        // Load the Pages
        if (method_exists($this, $page))
        {
            // die(get_include_path());
            require_once DOC_ROOT . '/views/inc/header.php';
            $this->$page();
            require_once DOC_ROOT . '/views/inc/footer.php';
        } 
        else
        {
            require_once DOC_ROOT . '/views/inc/header.php';
            $this->notFound();
            require_once DOC_ROOT . '/views/inc/footer.php';
        }

    }

    // Functions to load the various views
    function index()
    {
        // $data = $this->model->my_user_info();
        $this->load->view('myview.php', $data); 
    }

    // function header()
    // {
    //  $this->load->view('header.php', $data);
    // }

    // function footer()
    // {
    //  $this->load->view('footer.php' $data);
    // }

    function login()
    {
        $this->load->view('login.php', $data); 
    }

    function register()
    {
        $this->load->view('register.php', $data);
    }

    function notFound()
    {
        die('not found');
    }
}

?>


controller.php

<?php

    include_once 'load.php';

    // Local
    // define ('URL_ROOT', 'http://localhost/');

    // Remote
    define ('URL_ROOT', 'http://tomcat.cit.ipui.edu/alecory/Spring-2014/Assignment%202/');

    // define ('URI', $_SERVER['REQUEST_URI']);
    // Outputs for:
    //    Local  = /register                                        
    //    Remote = /alecory/Spring-2014/CIT-31300/Assignment%202/views/register.php
    define('URI', '/register'); // <= this is where I could set it myself and 
                                    # it would reroute the URL from
                                    # /Assignment%202/views/register.php   To         
                                    # /Assignment%202/ 
                                    # (only showing /Assignment%202/ in the URL)

    define ('DOC_ROOT', $_SERVER['DOCUMENT_ROOT']);
    //    Local  = /Applications/MAMP/htdocs/CIT-31300/Assignment 2
    //    Remote = /var/www/                       

?>
<?php 

/**
* Controller
* 
* Description: Basically tells the system what to do and in what order
*/
class Controller
{
    public $load;
    public $model;

    function __construct()
    {
        // Make
        $this->load  = new Load();
        $this->model = new Model();

        // Set the $page = current view/page
        $page = ltrim(URI, '/');

        // Set default page to index
        if (empty($page))
        {
            $page = 'index';
        }

        // Load the Pages
        if (method_exists($this, $page))
        {
            // die(get_include_path());
            require_once DOC_ROOT . '/views/inc/header.php';
            $this->$page();
            require_once DOC_ROOT . '/views/inc/footer.php';
        } 
        else
        {
            require_once DOC_ROOT . '/views/inc/header.php';
            $this->notFound();
            require_once DOC_ROOT . '/views/inc/footer.php';
        }

    }

    // Functions to load the various views
    function index()
    {
        // $data = $this->model->my_user_info();
        $this->load->view('myview.php', $data); 
    }

    // function header()
    // {
    //  $this->load->view('header.php', $data);
    // }

    // function footer()
    // {
    //  $this->load->view('footer.php' $data);
    // }

    function login()
    {
        $this->load->view('login.php', $data); 
    }

    function register()
    {
        $this->load->view('register.php', $data);
    }

    function notFound()
    {
        die('not found');
    }
}

?>


要获得答案,您需要定义(“不起作用”和“.”)第一个pelase;)不工作:页眉和页脚不加载期间。直接访问文件路径时将加载Body。ie:Assignment 2/views/register.phpNo错误消息?是否已打开错误报告以进行调试?是。在我的php.ini文件中。不可能<如果找不到文件,code>require_once将触发错误。如果没有得到任何错误,唯一的可能性是根本不调用
\uu construct()
方法。