来自数据库的2个php文件中的数据

来自数据库的2个php文件中的数据,php,html,mysql,Php,Html,Mysql,我有2个PHP文件。其中一个是运行大部分PHP代码的文件,另一个显示HTML页面 我想在我的第二个PHP页面上显示一些数据库信息(包括一些HTML)。问题是,我没有显示任何数据 我尝试在数据库结果上使用print\r(),但这些结果仅显示在第一页 让我用我的代码来解释我自己: 第一个PHP页面(test.PHP) 第二个PHP页面(test_view.PHP) //头文件 //主要内容 //检查数据库信息是否为数组,显示“不是数组” 是阵列 不是数组 //页脚文件 我的问题是,为什么它不在第二

我有2个PHP文件。其中一个是运行大部分PHP代码的文件,另一个显示HTML页面

我想在我的第二个PHP页面上显示一些数据库信息(包括一些HTML)。问题是,我没有显示任何数据

我尝试在数据库结果上使用
print\r()
,但这些结果仅显示在第一页

让我用我的代码来解释我自己:

第一个PHP页面(test.PHP)

第二个PHP页面(test_view.PHP)

//头文件
//主要内容
//检查数据库信息是否为数组,显示“不是数组”
是阵列

不是数组

//页脚文件

我的问题是,为什么它不在第二个页面上接收数据?

您是否从
test\u view.php
中得到任何显示?是的,它按它应该的方式显示页面,只显示“is not array”,而它应该是“is array!”。
标题中有任何冲突。php
?您确定$sInfo是一个数组吗?test.php中print_r($sInfo)的输出是什么?
$sInfo=$s->get(Session::get('user')$sInfo=$s->data()~第二个表达式覆盖第一个表达式
// Class Initialization, DB connection etc.
require_once 'core/init.php';

// Create instance of class Subscription
$s = new Subscription();

// Get results from the DB
$sInfo = $s->get(Session::get('user'));
$sInfo = $s->data();

// When print_r() is ran here it shows the DB results
print_r($sInfo);

// Include the second PHP file
require_once VIEW_ROOT . '/general/test_view.php';
// Header file
<?php require_once VIEW_ROOT . '/templates/header.php'; ?>

// Main content
<div class="container">
    <div class="wrapper">
        // Checking if the DB information is an array, "is not array" is shown
        <?php if(is_array($sInfo)): ?>
        <p>Is array!</p>
        <?php else: ?>
        <p>Is not array</p>
        <?php endif; ?>
    </div>
</div>

// Footer file
<?php require_once VIEW_ROOT . '/templates/footer.php'; ?>