You are here: Re: [PHP] Some questions about if and isset. « PHP « IT news, forums, messages
Re: [PHP] Some questions about if and isset.

Posted by Richard Lynch on 01/31/05 20:06

Geir Anders Berge wrote:
> I'm sure that this code can be written more efficient, please tell me how,
> but that's not my problem. The problem is that when i run this script all
> lines are executed. I'm sure I'm doing something wrong, but can't find out
> just what.

Okay, it's REALLY hard to see how all three tests could return TRUE...

But what is IN $variable and $constant?

>
> <?php
> if (isset($variable))
> {
> if ($variable < $constant)
> {
> Execute this code if $variable is less than $constant
> }
> if ($variable > $constant)
> {
> Execute this code if $variable is more than $constant
> }
> if ($variable == $constant)
> {
> Execute this code if $variable and $constant are equal
> }
> }
> else
> {
> Execute this code if $variable is not set
> }
> ?>

An alternative not yet mentioned:
if (isset($variable)){
switch (TRUE){
case ($variable < $constant):
break;
case ($variable > $constant):
break;
case ($variable == $constant):
break;
}
}
else{
}

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация