PHP Forum

PHP Forum (http://www.selfphp.de/forum/index.php)
-   PHP Grundlagen (http://www.selfphp.de/forum/forumdisplay.php?f=12)
-   -   anfängerproblem bei einem code (http://www.selfphp.de/forum/showthread.php?t=8888)

pascalplus 20.10.2004 22:36:52

anfängerproblem bei einem code
 
Wieso funktioniert folgender code nicht?

PHP-Code:

<?
$monate = array("jan", "feb", "mar", "April", "mai", "jun", "jul", "aug", "sep", "okt", "nov", "dez");  $monat = date("n");
$monat = $monate[$monat++];
if(!ststr($REQUEST_URI,"#".$monat))
{
header("Location: terminkalender.php#".$monat);
}
?>

Der code steht unmittelbar am anfang der datei terminkalender.php.

Er sollte zuerst, abfragen, welchen Monat wir zurzeit haben und danch zu diesem Abschnitt im gleichen dokument wechseln.

xabbuh 20.10.2004 22:48:09

Re: anfängerproblem bei einem code
 
PHP-Code:

<?
    $monate = array("jan", "feb", "mar", "April", "mai", "jun", "jul", "aug", "sep", "okt", "nov", "dez");
    $monat = date("n");
    $monat = $monate[$monat++];    //  <- $monat-- ist wohl sinnvoller
if(!ststr($REQUEST_URI,"#".$monat))
{    //  <- die Funktion ststr gibt es nicht, was genau soll hier überhaupt überprüft werden?
header("Location: terminkalender.php#".$monat);
}
?>


pascalplus 21.10.2004 14:26:31

PHP-Code:

<?

    $monate = array("jan", "feb", "mar", "April", "mai", "jun", "jul", "aug", "sep", "okt", "nov", "dez");

    $monat = date("n");

    $monat = $monate[$monat--];

if(!ststr($REQUEST_URI,"#".$monat))

{    //  <- hier soll geprüft werden, ob in der url #.$monat vorkommt, denn dann muss ja die seite nicht nochmal neu geladen werden

header("Location: terminkalender.php#".$monat);

}

?>


xabbuh 21.10.2004 14:40:40

PHP-Code:

<?
    $monate = array("jan", "feb", "mar", "April", "mai", "jun", "jul", "aug", "sep", "okt", "nov", "dez");
    $monat = date("n");
    $monat = $monate[$monat++];
if(!strstr($REQUEST_URI,"#".$monat))
{    //  <- strstr() wäre die richtige Funktion, allerdings wird #monat nicht in der Variablen $REQUEST_URI gespeichert
header("Location: terminkalender.php#".$monat);
}
?>



Alle Zeitangaben in WEZ +2. Es ist jetzt 23:37:47 Uhr.

Powered by vBulletin® Version 3.8.3 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.