PDA

View Full Version : PHP If statement issue


rowlandc
05-27-2008, 06:50 AM
Hi guys,

I need a little bit of help with solving an issue which we are getting with this php statement.

if(isset($value)) {
echo "true";
} else {
echo "false";
}

Currently whats happening is that both true and false appear... we've never seen this happen before and wanted to know if you guys would have clue why both echo at the same time.

Dismounted
05-27-2008, 07:10 AM
if ($value)
{
echo 'true';
}
else
{
echo 'false';
}
isset() simply checks if the variable exists, regardless of value.

rowlandc
05-27-2008, 07:34 AM
The value returned has nothing to do with the issue...

Dismounted
05-27-2008, 07:40 AM
Right, sorry, I misinterpreted your question. That should never happen, and really can't happen, as an if/else statement can only run either block, not both.

rowlandc
05-27-2008, 07:43 AM
Right, sorry, I misinterpreted your question. That should never happen, and really can't happen, as an if/else statement can only run either block, not both.

Aye thats what we where thinking.... it's bizzare.

--------------- Added 1211881849 at 1211881849 ---------------

Anyone else have a clue what could be happening?

Opserty
05-27-2008, 12:53 PM
Run this and copy and paste the exact output (preferably from the HTML source):


echo '------- START -------';

if(isset($value))
{
echo 'true';
}
else
{
echo 'false';
}

echo '------- VAR -------';

var_dump($value);

echo '------- END -------';

rowlandc
05-28-2008, 06:46 AM
fixed, I had to get the coder to type of the whole code by hand. It seems like the files where not uploading correctly.

Thank you for the help.