[英]how to add the values stored in a session variable in php?
Okay 好的
I have two pages-- page1.php and page2.php .Both of these pages have select lists.I have posted the values selected by the user to script.php which has them stored in session variables. 我有两个页面-page1.php和page2.php。这两个页面都有选择列表。我已经将用户选择的值发布到script.php中,并将它们存储在会话变量中。
I need to add the values (which are the ones selected by the user from the select lists in both the pages) and display this total value in page3.php.now how do i add these values in the script? 我需要添加值(这是用户从两个页面的选择列表中选择的值),并在page3.php中显示此总值。现在如何在脚本中添加这些值?
any suggestions would be helpful.thanks in advance. 任何建议都将有所帮助。
If I get your problem correctly, you can just fetch values directly from $_SESSION variable: 如果我正确地解决了您的问题,则可以直接从$ _SESSION变量中获取值:
$total = $_SESSION['value1'] + $_SESSION['value2'];
Of course you should also check if the session variables are set at all and are correct (numeric). 当然,您还应该检查会话变量是否全部设置并且正确(数字)。 The $_SESSION (and not $_session!) is one of the "superglobal" variables in PHP - read more .
$ _SESSION(而不是$ _session!)是PHP中的“超全局”变量之一- 阅读更多内容 。
$_session['var1] + $_session['var2']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.