【问题标题】:while including another page in php codeigniter the parent page not loading在 php codeigniter 中包含另一个页面时,父页面未加载
【发布时间】:2019-09-22 02:09:51
【问题描述】:

我在 codeigniter 中做一个项目,所有页面都是使用 mvc,codeigniter 框架完成的。我已经用纯 php 做了几页并将其保存在根文件中。像以下页面: 库.php 数据库连接.php

索引页面是使用框架完成的,我尝试包含如下 library.php 文件:

<?php


// Start Session
session_start();

// Application library ( with ShopingCart class )
require __DIR__ . 'library.php'

$app = new ShopingCart();

$products = $app->getProducts();

?>

在索引页的顶部。

library.php 开始如下:

<?php

// load database connection script

include("database_connection.php");

/*
 * Tutorial: PHP MySQL Shopping cart
 *
 * Page: Application library
 * */

class ShopingCart
{



    protected $db;

    function __construct()
    {
        $this->db = DB();
    }

现在的问题是当我加载索引页面时,它甚至没有加载显示以下错误:

此页面不工作 localhost 当前无法处理此请求。 HTTP 错误 500

我认为这是因为我试图将文件包含在页面中,我该如何摆脱它?

【问题讨论】:

    标签: php jquery html mysql codeigniter


    【解决方案1】:

    Http error 500 代表服务器错误。

    这里有语法错误

    require __DIR__ . 'library.php'
    

    你忘了;

    【讨论】:

    • 这不是语法错误,我昨天自己更正了。页面是空白的
    猜你喜欢
    • 1970-01-01
    • 2011-06-04
    • 2012-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-08
    相关资源
    最近更新 更多