如何在php脚本之间传递变量? [英] How to pass variables between php scripts?
本文介绍了如何在php脚本之间传递变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在php脚本之间传递值和变量?
Is there any way to pass values and variables between php scripts?
正式地,我尝试对登录页面进行编码,当用户首先输入错误的输入时,另一个脚本将检查输入,如果输入错误,站点将返回到最后一个脚本页面并显示诸如输入错误"之类的警告.为此,我想我需要从脚本中传递值.
Formally, I tried to code a login page and when user enter wrong input first another script will check the input and if it is wrong, site returns to the last script page and show a warning like "It is wrong input". For this aim, I need to pass values from scripts I guess.
问候...:P
推荐答案
通过 GET 传递信息:
header('Location: otherScript.php?var1=val1&var2=val2');
会话:
// first script
session_start();
$_SESSION['varName'] = 'varVal';
header('Location: second_script.php'); // go to other
// second script
session_start();
$myVar = $_SESSION['varName'];
发布:看看这个一>.
这篇关于如何在php脚本之间传递变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文