$_POST
如果在or中没有设置任何内容,我正在尝试获取第一个条目,$_SESSION
但是当我使用输出以下内容时,die(print_r($nmcu));
我总是只得到 1,如果我在“条目 1”和“出口 2”的末尾添加数字,它似乎可以工作但是我不知道为什么,我不想要名字中的数字......
<?php
session_start();
$entry = array(
"entry" => array("user" => "username",
"pass" => "password",
"host" => "localhost",
"port" => 1111,
"protocol" => "http"),
"exit" => array("user" => "username",
"pass" => "password",
"host" => "localhost",
"port" => 1111,
"protocol" => "http"));
if (isset($_POST['currentEntry'])) {
$_SESSION['currentEntry'] = $_POST['currentEntry'];
}
if (isset($_SESSION['currentEntry'])) {
$currentEntry = $_SESSION['currentEntry'];
} else {
$keys = array_keys($entry);
$currentEntry = $keys[0];
$_SESSION['currentEntry'] = $currentEntry;
}
$nmcu = $entry[$currentEntry];
?>