想从另一个页面回显一个php变量 [英] Want to echo a php variable from another page
问题描述
我想在页面上回显一个变量,我将其包含在一个不同的页面中。这样可以节省空间并尽可能地将PHP代码与文本数据分开。
I want to echo a variable on a page which I've included form a different page. This to save space and separate php code from text data as much as possible.
在我获取变量的页面中(让我们称之为aa.php)我有:
In the page from where I fetch the variables (let's call it "aa.php") I have:
if ($whatever=="A") echo "somethingA";
if ($whatever=="B") echo "somethingB";
if ($whatever=="C") echo "somethingC";
我将它包含在我希望数据显示的页面上(让我们称之为data.php) ):
I include it on the page where I want the data to show (let's call it "data.php"):
include 'aa.php';
$whatever = "B";
我想在data.php上显示B,但它不会在页面上回显所有(我猜是因为它实际上是在另一页上?) - 如何在我希望数据显示的页面上回显它,尽可能少的杂乱?
I want "B" to show on data.php, but it isn't echoing on the page at all (I'm guessing because it's actually on the other page?) -- How do I echo it on the page where I want the data to show, with as little clutter as possible?
推荐答案
订单似乎是问题所在:
$whatever = "B";
include 'aa.php';
这篇关于想从另一个页面回显一个php变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!