将一个变量值从一个 php 页面传递到另一个 [英] Pass a variable value from one php page to another
问题描述
我正在尝试从 wordpress 存档页面发送这个 php get_field 变量的值.
I'm trying to send the value of this php get_field variable from a wordpress Archive page.
get_field('supplier_email_address', 'product_brand_' . $term->term_id );
到另一个 sendmessage.php 页面,除了使用 JS 发送表单外,该页面永远不会被访问.我需要填充的变量叫做:
to another sendmessage.php page which is never accessed other than with the of JS to send a form. The variable I need filled is called:
$sendto="value";
我怎样才能做到这一点?
How can I achieve this?
显然这需要更多信息.
推荐答案
使用会话变量.
首先,您要使用会话的每个页面都需要具有函数 session_start();在每一页的顶部声明.然后你可以使用会话超全局来存储东西.
First of all every page you want to use sessions on needs to have the function session_start(); declared at the top of every page. You then can use the session superglobal to store things.
Pg1.php:
<?php
session_start();
$_SESSION['variable_name'] = 'string';
?>
Pg2.php:
<?php
session_start();
echo $_SESSION['variable_name'];
?>
Pg2.php will show: some string
这篇关于将一个变量值从一个 php 页面传递到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!