RE: isset question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The isset or empty, it's return a boolean (true 1, false 0), the isset will return true if the variable will have been initiated, the empty will return true if the variable is empty, but for that the variable need to be initiated. You can do it in a many ways, like:


$msg.= (isset($_POST['mort']) && !empty($_POST['mort']) ? "The mortgage amount is  $mort\n" : " ");

or

$msg.= ($_POST['mort'] == '' ? "The mortgage amount is  $mort\n" : " ");

or

$msg.= (strlen($_POST['mort']) > 0 ? "The mortgage amount is  $mort\n" : " ");



Yuri Yarlei.
Programmer PHP, CSS, Java, PostregreSQL;
Today PHP, tomorrow Java, after the world.
Kyou wa PHP, ashita wa Java, sono ato sekai desu.



> Date: Thu, 18 Jun 2009 20:07:09 +0100
> From: stuttle@xxxxxxxxx
> To: gwpaul@xxxxxxx
> CC: php-general@xxxxxxxxxxxxx
> Subject: Re:  isset question
> 
> 2009/6/18 Gary <gwpaul@xxxxxxx>:
> > I have a form that gives the submitter a choice or either one set of
> > questions, or another. I am still getting the message even if the input was
> > left blank.  So on the line below,
> >
> > $msg.=  isset($_POST['mort']) ? "The mortgage amount is  $mort\n" : " ";
> >
> > I get
> >
> > The mortgage amount is
> >
> > What am I missing here?
> 
> A variable "isset" even if it's empty. Either compare it to an empty
> string or test the result from strlen against 0.
> 
> -Stuart
> 
> -- 
> http://stut.net/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

_________________________________________________________________
Conheça os novos produtos Windows Live! Clique aqui.
http://www.windowslive.com.br

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux