Folgende Frage: Ich möchte die globale Variable $HTTP_GET_VARS in einer Funktion auslesen was leider nicht gelingt. Ohne Funktion funzt alles. Wo liegt das Problem ? Globale Vari sollten doch überall gelten, auch in Funktionen!
Hier der Testquelltext:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
</head>
<body bgcolor="white">
<?php
function hol_var(){
$vorname = $HTTP_GET_VARS["wgid"];
$vorname_= ",".$vorname.",".$n.",".$d.",".$r;
return $vorname_;
}
?>
<br>
<p>
<?php
echo "<a href=\"post.php?wgid=2\"" ;
echo "title=\"\">";
echo "link_wgid=2";
echo "</a><br><br>";
echo "<a href=\"post.php?wgid=3\"" ;
echo "title=\"\">";
echo "link_wgid=3";
echo "</a><br><br>";
echo "<br><br>";
$vorname = $HTTP_POST_VARS["vorname"];
$nachname = $HTTP_GET_VARS["wgid"];
$email = $HTTP_GET_VARS["wgid_"];
print "<strong>Vorname</strong>: $vorname<br />";
print "<strong>Nachname</strong>: $nachname<br />";
print "<strong>E-Mail</strong>: $email<br />";
Next
?>
<br>
<p>
<form method="post">
<input type="text" name="vorname" size="20" />Vorname<br/>
<input type="text" name="nachname" size="20" />Nachname<br/>
<input type="text" name="email" size="20" />E-Mail<br/>
<input type="submit" name="submit" value="Abschicken" />
</form>
</p>
<?php
$email = $HTTP_GET_VARS["wgid_"];
$nachname = $HTTP_GET_VARS["wgid"];
echo "<a href=\"post.php?wgid_=4\"" ;
echo "title=\"\">";
echo "link_wgid_=4";
echo "</a><br><br>";
echo "<strong>Nachname</strong>: $nachname<br />";
echo "<strong>E-Mail</strong>: $email<br />";
echo "<br>";
$email = $HTTP_GET_VARS["wgid_"]; ?>
<br>hier
<?php echo $a = hol_var();
echo "<br>";
echo $vorname = $HTTP_GET_VARS["wgid"];
?>
</body>
</html>
Hier der Testquelltext:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
</head>
<body bgcolor="white">
<?php
function hol_var(){
$vorname = $HTTP_GET_VARS["wgid"];
$vorname_= ",".$vorname.",".$n.",".$d.",".$r;
return $vorname_;
}
?>
<br>
<p>
<?php
echo "<a href=\"post.php?wgid=2\"" ;
echo "title=\"\">";
echo "link_wgid=2";
echo "</a><br><br>";
echo "<a href=\"post.php?wgid=3\"" ;
echo "title=\"\">";
echo "link_wgid=3";
echo "</a><br><br>";
echo "<br><br>";
$vorname = $HTTP_POST_VARS["vorname"];
$nachname = $HTTP_GET_VARS["wgid"];
$email = $HTTP_GET_VARS["wgid_"];
print "<strong>Vorname</strong>: $vorname<br />";
print "<strong>Nachname</strong>: $nachname<br />";
print "<strong>E-Mail</strong>: $email<br />";
Next
?>
<br>
<p>
<form method="post">
<input type="text" name="vorname" size="20" />Vorname<br/>
<input type="text" name="nachname" size="20" />Nachname<br/>
<input type="text" name="email" size="20" />E-Mail<br/>
<input type="submit" name="submit" value="Abschicken" />
</form>
</p>
<?php
$email = $HTTP_GET_VARS["wgid_"];
$nachname = $HTTP_GET_VARS["wgid"];
echo "<a href=\"post.php?wgid_=4\"" ;
echo "title=\"\">";
echo "link_wgid_=4";
echo "</a><br><br>";
echo "<strong>Nachname</strong>: $nachname<br />";
echo "<strong>E-Mail</strong>: $email<br />";
echo "<br>";
$email = $HTTP_GET_VARS["wgid_"]; ?>
<br>hier
<?php echo $a = hol_var();
echo "<br>";
echo $vorname = $HTTP_GET_VARS["wgid"];
?>
</body>
</html>
Kommentar