Jump to content

Recommended Posts

umm i want to check if the user visiting the page has 2 character
1 male/trans
1 female/trans
and only continue if the user owns one of those character
[code]<?php if ($char1 == "Male" && $char2 == "Female" OR $char1  == "Male" && $char2 == "Trans" OR $char1 == "Female" && $char2 == "Male" OR $char1 == "Female" && $char2 == "Trans" OR $char1 == "Trans" && $char2 == "Male" OR $char1 == "Trans" && $char2 == "Female" OR $char1 == "Trans" && $char2 == "Trans")
{
echo"You have a pair.";
}
?>[/code]

will this work?
Link to comment
https://forums.phpfreaks.com/topic/16707-will-or-work/
Share on other sites

you need extra braces i beleave

[code]<?php if (($char1 == "Male" && $char2 == "Female") OR ($char1  == "Male" && $char2 == "Trans") OR ($char1 == "Female" && $char2 == "Male") OR ($char1 == "Female" && $char2 == "Trans") OR ($char1 == "Trans" && $char2 == "Male") OR ($char1 == "Trans" && $char2 == "Female") OR ($char1 == "Trans" && $char2 == "Trans"))
{
echo"You have a pair.";
}
?>[/code]

AndyB I think that he has some kinda game script or sumet and he wants to check if they have 2 diffrent variables selected which means they make up a pair..

Regards
Liam
Link to comment
https://forums.phpfreaks.com/topic/16707-will-or-work/#findComment-70204
Share on other sites

OR is the same as ||, AND is the same as &&, bitwise or (|) bitwise and (&)

P.S.: can someone tell me what the & does when used in one of the following ways:

$Var &= $Var2; // object or something?
function myfunction(&$var); // Here, i believe you need to provide an already declared variable

if you know also otherways the & can be used, please let me know..
Link to comment
https://forums.phpfreaks.com/topic/16707-will-or-work/#findComment-70208
Share on other sites

When used thus: "myfunction(&$var);" you are passing a reference to the variable, not a copy of it.  Which means that if the function alters the value, the original variable gets altered and stays altered after the function returns, rather than a copy of the variable being altered and then thrown away when the function returns.

I guess "$var &= $var2" would logically and the values and stored the result in $var, so if they were 195 (binary 11000011) and 144 (binary 10001000) the result would be 128 (binary 10000000) but I've never used it in PHP (and seldom in C).
Link to comment
https://forums.phpfreaks.com/topic/16707-will-or-work/#findComment-70212
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.