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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序