duanniedang3946 2019-05-03 13:59
浏览 50
已采纳

同时在php codeigniter中包含另一个页面,不加载父页面

i am doing a project in codeigniter, all the pages are done using mvc, the codeigniter framework. i have done a few pages in plain php and kept it in the root file. like the following pages: library.php database_connection.php

the index page is done using the framework, and i tried including the library.php file as below:

<?php


// Start Session
session_start();

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

$app = new ShopingCart();

$products = $app->getProducts();

?>

at the top of the index page.

library.php starts like below:

<?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();
    }

now the problem is when i am loading the index page, its not even loading showing the following error:

This page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500

i think its because i am trying to include the file in the page, how can i get rid of this ?

</div>
  • 写回答

1条回答 默认 最新

  • duanjunjie0196 2019-05-03 16:57
    关注

    Http error 500 stands for a server error.

    You have a syntax error here

    require __DIR__ . 'library.php'
    

    your forgot ;

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失