Author | Message | Time |
---|---|---|
idiat | OK, so I've got this function, right. It goes a little something like this: [code]function ConnectBNCS($quiet) { ap(BNCS, yellow, "Inside Connect"); global $BNCS, $config; if (!$quiet) ap(BNCS, yellow, "Connecting..."); ap(BNCS, yellow, $config["server"]); $BNCS = new PacketBuffer; if (!$BNCS->Connect($config["server"], 6112)) { ap(BNCS, red, "Connection failed."); exit; } ap(BNCS, yellow, "Inside Connect3"); if (!$quiet) ap(BNCS, green, "Connected!"); ap(BNCS, yellow, "Inside Connect4"); }[/code] And when I call it like so: [code] ConnectBNCS(false);[/code] All it does is output: [6:15:38 PM] [BNCS] Inside Connect [6:15:39 PM] [BNCS] useast.battle.net [6:15:39 PM] [BNCS] Inside Connect3 [6:15:39 PM] [BNCS] Inside Connect4 Why? | May 8, 2007, 11:25 PM |
rabbit | Because ! is a binary operator. Use == false or != true. | May 9, 2007, 12:46 AM |
idiat | That didn't change anything either, though that is interesting to know. I've tried: -Using $quiet == false instead -Using $quiet == true ($quiet is true incidentally, even though I set it to false) -Setting $quiet to 0 instead of false -Setting $quiet to an arbitrary number (52), it still appeared as 1 throughout the function -Reorganizing the if statement in many different ways -Using a different name for $quiet -Restarting Apache -Restarting computer -Resetting PHP configuration It worked before and I didn't make any changes to the code to break it. Also, it's NOT connecting to the specified server, (figured out while trying to connect to localhost instead), even though it has before, to the point where I've been able to log in and chat. | May 9, 2007, 1:03 AM |
warz | im going to go out on a limb here, but im willing to bet that something is wrong, or is not working how you intend it to be working. | May 9, 2007, 8:11 AM |
idiat | omg how'd you know?! I intend for $quiet to be set according to what I set it to but PHP is setting it to 1 on its own accord. | May 9, 2007, 12:30 PM |
St0rm.iD | Could this be related to register_globals? | May 9, 2007, 4:40 PM |
iago | [quote author=idiat link=topic=16682.msg168874#msg168874 date=1178713838] omg how'd you know?! I intend for $quiet to be set according to what I set it to but PHP is setting it to 1 on its own accord. [/quote] He has a point, even if he said it in a round-about way. The code that I can see is correct. There is absolutely nothing wrong with the code you posted there. Here's a test I did to confirm that: [pre]ron@facevision:~$ cat test.php <?php function test($quiet) { if(!$quiet) print "Noisy!!\n"; } print "True: "; test(true); print "\nFalse: "; test(false); print "\n"; ?> ron@facevision:~$ php test.php True: False: Noisy!! [/pre] Obviously, something else is pooched. Check the value of $quiet within that function. Check for multiple functions with the same name, old versions of files, and misspellings. | May 9, 2007, 6:12 PM |
idiat | I tested the exact same code on Ubuntu and it works correctly. :-/ | May 9, 2007, 9:08 PM |
iago | In that case, perhaps you're using a weird/broken version of PHP. Try using the "===" operator, "if($quiet === false)". I doubt it'll make a difference, but it's worth a try. | May 9, 2007, 10:20 PM |
Myndfyr | [quote author=rabbit link=topic=16682.msg168847#msg168847 date=1178671562] Because ! is a binary operator. Use == false or != true. [/quote] ! is not a binary operator. It's a unary operator. | May 17, 2007, 4:16 PM |
rabbit | Bleh...wrong word. I've never had all them formal teachins like youse did. | May 17, 2007, 5:10 PM |