Perhaps its an obvious question, but really: Is if(somthing){ //do things } PHP: equal to if(somthing==true){ //do things } PHP: ?
if "something" is returning true then only the block will gets executed. for example: <?php something = false; if(somthing){ //do things } ?> Then the block will not gets executed The condition "something" must return true to execute the code. in same is true for the second example.
function something() { $something = "?????"; // get the something if (empty($something)) { $something = $something_else; // possible default } return $something; } PHP:
Wow, I swear the people responding are trying to confuse you. Here's the answer you are looking for: yes
if(false) { // wont get executed } if(null) { // wont get executed } if(0) { // wont get executed } if("false") { // will get executed } if("null") { // will get executed } if("string"==true) { // will get executed } if("false"==false) { // wont get executed } if("false"==true) { // will get executed } if("true"==false) { // wont get executed } if("true"==true) { // will get executed } PHP: And soooooo on (cases with 0, "0", null and "null"). It can get pretty confusing =)
its a php situation and better defined if we knew the if = You cant just say it equals 1 or 0, true or false // thats a result
Is an elephant a house? Well, what kind of elephant--asian or african? Do you consider an apartment a house? This isn't a toy elephant is it? Do you want to paint the house or get aluminum siding? Do you know how much elephants eat in a day? You are all missing his question. He doesn't care about specific values of the variable something. He wants to know if those two conditional tests are equivalent.
Hey there, Which still is a 'maybe', because we don't know what 'something' is. I guess if he had something like $something = false; if($something == true) { // i will fail } then what he's asking should stand correct, assuming $something is a defined variable. Granted, i'm not sure why you would do that Odd question either way! Francisco