我遇到了一个问题,即我在外部 php 脚本中声明的变量没有显示在稍后通过 jquery 加载的页面的一部分中。
简化代码:
索引.php:
<?php
require_once "init.php";
?>
//the rest of the page is added here.
初始化文件
<?php
$test = 'foo';
?>
主页.php
<?php
echo $test;
?>
单击 div 时,jquery 将使用 .load 将 'home.php' 添加到页面中。
问题是 $test var 没有显示,因为页面上没有使用 'home.php' 运行 'init.php'。有什么办法可以解决这个问题吗?
谢谢