我只需要运行该程序一次;之后它将运行另一个程序。这怎么可能?
if()
{
include 'first.php';
}
else
{
include 'second.php';
}
我不想在 if 条件中添加条件。
请问有人可以帮忙吗?
最佳答案
在 $_SESSION 中存储一个标志,标记您的first.php已经运行过一次,如下所示:
if(!isset($_SESSION['first_run'])){
$_SESSION['first_run'] = 1;
include 'first.php';
}
include 'second.php';
关于php - 在 php 中只运行一次代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9682229/