$_GET变量在其他函数中为为什么的不到值?
这个测试文件:
aaa.php
<html>
<head>
<title>测试get变量</title>
</head>
<body>
<table>
<tr>
<td><a href="test.php?ids=2">测试</a></td>
</tr>
</table>
</body>
test.php
<?
$thisprog = "test.php";
if(empty($_POST['action']))
{
test_index();
exit;
}
elseif($_POST['action'] == "add")
{
test_add();
exit;
}
function test_index()
{
global $thisprog;
echo $_GET['ids'];//这里的值是2
?>
<form action="<?=$thisprog?>" method="POST">
<table>
<tr>
<td>
<input type="text" name="title" size="8">
<input type="hidden" name="action" value="add">
<input type="submit" name="submit" value="测试">
</td>
</tr>
</table>
</form>
<?
echo $_GET['ids'];//这里的值也是2
}
function test_add()
{
echo $_GET['ids'];//这里就没有值了,为什么?
echo $_POST['title'];
}
?>
为什么在test_add()函数中的不到通过点击test.php?ids=2传递过来的
$_GET['ids']的值呢?