[UPHPU] More if then fun...

District Webmaster webmaster at alpine.k12.ut.us
Wed Apr 28 12:23:56 MDT 2004


D'oh!

My previous explanation contained an error -- Kenneth is correct that &&
is evaluated before || (How very embarrassing for me! Unsend!
Unsend!!!!)

But, again, since you have an || in which one side evaluates to true,
your statement will always evaluate as true.

Dave

>>> "Kenneth Burgener" <email at kennethburgener.com> 04/28/04 12:11 PM >>>
Looks like an order of operations problem...

if( false or false ) = false

if( true or (false and false) ) = true
*Remember ANDs get processed before ORs

The logic is correct for the output.  What are you trying to do?


-----Original Message-----
From: Ashley Oviatt [mailto:ashovi at qwest.net]
Sent: Wednesday, April 28, 2004 12:05 PM
Cc: UPHPU List
Subject: [UPHPU] More if then fun...


Can someone explain to me why the first if statement works (doesn't 
produce the output,) and the second one doesn't work (Does produce the 
output)?

I'm assuming the syntax of the second if statement is wrong, but I don't

know why.

<?php
	$text = "";	
	$k = "Website";

// First if statement
	if ($k == "Websites" || $k == "Email_Address")
	{
         if ($text !="")
		{
		print "hello I am the first test";
		}
	}

//Second if statement.
	if ($k == "Website" || $k == "Email_Address" && $text !="")

		{
		print "hello I am the second test";
		}
?>


The output of the code is : hello I am the second test

???



---------------------------------------------------------------------
To unsubscribe, e-mail: list-unsubscribe at uphpu.org
For additional commands, e-mail: list-help at uphpu.org








---------------------------------------------------------------------
To unsubscribe, e-mail: list-unsubscribe at uphpu.org
For additional commands, e-mail: list-help at uphpu.org






More information about the UPHPU mailing list