Visualizzazione dei risultati da 1 a 3 su 3

Discussione: variabili

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2005
    Messaggi
    138

    variabili

    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.

  2. #2

    Re: variabili

    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.
    ECHO $_GET[var]

  3. #3
    Come faccio a testare se una variabile nella querystring, non proveniente da un form, è vuota o meno?
    dal manuale di php:
    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.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.