[Pugged] Alright, my turn

Bryan Baker ciapug@ciapug.org
Tue, 24 Sep 2002 21:57:50 -0500


On Tuesday, September 24, 2002, at 06:02  PM, Chris Van Cleve wrote:
> I'll try it the simpler way Bryan mentioned and see how that goes. it 
> just seems odd to me that anything gets authorized except 0. That 
> throws me a bit.
>

as I said, if it is evaluating only the bang and the var and you're 
using this as a dis-allow test it makes perfect sense.

<?php
##########################
# truth.php - logic demo #
##########################

//this is true
$foo = 0;
if (!$foo)  {
	print ("I'm true 1<br>");
} else {
	print ("I'm false 1<br>");
}

//this is false
$foo = 1;
if (!$foo) {
      print ("I'm true 2<br>"); //It'll never print
} else {
     print ("I'm false 2<br>");
}

//this is false
$foo = 49;
if (!$foo) {
      print ("I'm true 3<br>"); //It'll never print either
} else {
     print ("I'm false 3<br>");
}

$auth = 50;

//this is false - simplified version of what you had
$foo = 0;
if(!$foo > $auth) {
	print ("I'm true 4<br>");//It'll never print either
} else {
	print ("I'm false 4<br>");
}

//this is false
$foo = 40;
if(!$foo > $auth) {
	print ("I'm true 5<br>");//It'll never print either
} else {
	print ("I'm false 5<br>");
}

//this is true - because it says !(Expression) - it evaluates the 
expression first
$foo = 40;
if(!($foo > $auth)) {
	print ("I'm true 6<br>");
} else {
	print ("I'm false 6<br>");
}

//this is true - it simplifies the logic - instead of negating a ">" 
you use the opposite sign
$foo = 40;
if($foo < $auth) {
	print ("I'm true 7<br>");
} else {
	print ("I'm false 7<br>");
}

//this is false - but you want it to be
$foo = 60;
if(!($foo > $auth)) {
	print ("I'm true 8<br>");
} else {
	print ("I'm false 8<br>");
}

//this is false - but you want it to be
$foo = 60;
if($foo < $auth) {
	print ("I'm true 9<br>");
} else {
	print ("I'm false 9<br>");
}


?>

--
Bryan Baker
  __
//\\  ASCII Ribbon Campaign     | Remember -
\\//  No HTML/RTF in email      | You can't get a virus from ASCII!
  XX\  No Word docs in email     | No one ever said "I can't read that
// \\ Respect open standards    | ASCII email you sent."