从一个PHP页面获取数据并将其显示在另一个PHP页面上(Grab data from one PHP page and display it on another)

编程入门 行业动态 更新时间:2024-10-25 06:31:36
从一个PHP页面获取数据并将其显示在另一个PHP页面上(Grab data from one PHP page and display it on another)

我不认为我这样做是正确的,但是这里就是这样。 我想能够有两个php页面mypage.php和mypage2.php 。 mypage2.php有纯文本数据(例如一个8位数字),它只是通过echo命令显示。

我想知道当我在mypage.php时,如果我可以抓住该号码并将其显示在mypage.php而不是打开mypage2.php并在那里显示它?

所以mypage.php的假设示例可能是:

echo "My secret number is: " . magic_command("mypage2.php");

我知道这样做的一种方法是使用$_SESSION ,但这不涉及仍然导航到mypage2.php ,将数字存储在$_SESSION 。 然后告诉它回到mypage.php ?

I do not think that I am doing this the right way, but here goes it. I want to be able to have two php pages mypage.php and mypage2.php. mypage2.php has plain text data on it (say a 8 digit number) and it is just being displayed via the echo command.

I want to know if when I am on mypage.php if I can grab that number and display it on mypage.php rather than open up mypage2.php and display it there?

So a hypothetical example of mypage.php might be:

echo "My secret number is: " . magic_command("mypage2.php");

I know that one way to do this is with $_SESSION, but doesn't that involve still navigationg to mypage2.php, storing the number in $_SESSION. Then telling it to go back to mypage.php?

最满意答案

你可以做:

include 'mypage2.php';

在mypage.php和mypage2.php :

echo '12345678';

易如反掌!

You can do:

include 'mypage2.php';

in mypage.php and in mypage2.php:

echo '12345678';

Easy as pie!

更多推荐

本文发布于:2023-07-29 20:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319540.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   数据   并将其   PHP   display

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!