如何从一个PHP页面访问变量到另一个,没有表单,链接或按钮? [英] How to access a variable from one PHP page to another, without a form, link, or button?

查看:223
本文介绍了如何从一个PHP页面访问变量到另一个,没有表单,链接或按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TLDR: - 从一个 PHP文件中传递变量的内容的好方法到另一个不涉及表格链接按钮

TLDR:- What is a good way to pass contents of a variable from one PHP file to another without involving a form, link or a button.

问题: -

所以有一个<名为 question_edit_form.php 的页面/文件中的code>表单及其操作属性已设置为另一个名为 question.php 的文件。 感兴趣的变量正在用户在 question_edit_form.php 中读入,然后显然被发送到 question.php 使用 $ _ POST

So there is a form in a page/file called question_edit_form.php and its action attribute is already set to another file called question.php. The variable of interest is being read-in from the user in question_edit_form.php and is then obviously being sent to question.php using $_POST.

现在,有第三个文件,名为 renderer.php ,并且没有链接到其他两个文件。 我想在此文件中使用该感兴趣的变量。 那么如何从renderer.php中访问question.php中设置的变量?

Now, there is a third file, named renderer.php, and which is not linked to the other two files. I want to use that variable of interest in this file. So how can I access that variable which is set in question.php from inside renderer.php?

推荐答案

您可以将变量存储在会话中。

You can store the variables in the session.

http://www.w3schools.com/php/php_sessions.asp

这篇关于如何从一个PHP页面访问变量到另一个,没有表单,链接或按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆