如何从一个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.