Come faccio a testare se una variabile nella querystring, non proveniente da un form, è vuota o meno?
Esempio
Url:
http://forum.html.it/forum/newthread.php?var=
Devo testare se var esiste e se è vuota.
Come faccio a testare se una variabile nella querystring, non proveniente da un form, è vuota o meno?
Esempio
Url:
http://forum.html.it/forum/newthread.php?var=
Devo testare se var esiste e se è vuota.
ECHO $_GET[var]Originariamente inviato da medp
Come faccio a testare se una variabile nella querystring, non proveniente da un form, è vuota o meno?
Esempio
Url:
http://forum.html.it/forum/newthread.php?var=
Devo testare se var esiste e se è vuota.
dal manuale di php:Come faccio a testare se una variabile nella querystring, non proveniente da un form, è vuota o meno?
Codice PHP:
---------------------------------------------
$var = 0; //nel tuo caso $_GET['var'];
---------------------------------------------
// ESEMPIO 1 uso di empty();
// Valuata come true perchè $var è vuota
if (empty($var)) { // restituisce true
print '$var è uguale a 0 oppure non è definita';
}
-------------------------------------------------
// ESEMPIO 2 uso di isset();
// Valutata come vera perchè $var è impostata
if (!isset($var)) { // restituisce false
print '$var non è definita';
}
--------------------------------------------------
www.bitmade.com Momentan ist richtig_Momentan ist gut_Nicht ist wirklich wichtig_Nach der Ebbe kommt die Flut_ _Am Strand des Lebens_ohne Grund,ohne Verstand_ist nichts vergebens_ich baue di traeume auf den Sand.