Is it possible to add two conditions in an If statement, and how can I do that? To clarify, this is what I want:
If $product is bigger than X when $factor is Y, return $something.
Thanks in advance everybody!
Use && to connect the conditions when you want both of them to be true. You also need to think about what to return if either or both conditions are false. For more information, read the PHP manual on logical operators.
There's a small problem though.
My $a doesn't have any value; I'm assigning $b different values and checking whether or not $a is greater than a set number.
Example:
$formula = $b + 150
If $formula > 200 when $b = 49, return something If $formula > 200 when $b = 50, return something
and so on...
I am afraid that I do not understand your example, since it looks like in both cases listed you will never return anything as $formula > 200 implies that $b > 50. I suggest that you describe what exactly you are trying to do, and provide a more complete and accurate example.
Ehh, I only asked as an attempt to shorten a code I had in mind. It's only 20 - 30 lines long so I settled with it.
Thanks though, laserlight. Those logical operators will help me in future cases.
Confessions wrote:My $a doesn't have any value; I'm ... checking whether or not $a is greater than a set number.
My $a doesn't have any value; I'm ... checking whether or not $a is greater than a set number.
Well, if $a doesn't have any value then the answer is going to be "no".
Let's put it this way: explaining something to a human is easier than explaining it to a computer. So if you can't explain it to a human....