Jump to content
MakeWebGames

PHP Pperators Help


Razor42

Recommended Posts

Hi guys,

I am working on something and I need to so that if three things are correct then the code runs. I have this:

if($codeone == $fcr['codeone'] && $codetwo == $fcr['codetwo'] && $codethree == $fcr['codethree']) 

 

But this doesn't seem to work. Anyone care to shed some light on my issues? :)

Link to comment
Share on other sites

if(($codeone == $fcr['codeone']) && ($codetwo == $fcr['codetwo']) && ($codethree == $fcr['codethree'])) 

 

Have to wrap each individual condition.

Not always true.

 

<?php

$testone = '5';
$testtwo = 'six';
$testthree = 'l';

if($testone == 5 && $testtwo == 'six' && $testthree == 'l')	{

echo 'true';

}	else	{

echo 'false';

}

?>

 

echoes out true, so does this:

 

<?php

$testone = '5';
$testtwo = 'six';
$testthree = 'l';

if(($testone == 5 || $testtwo == 'si') && $testthree == 'l')	{

echo 'true';

}	else	{

echo 'false';

}

?>

 

It all depends what you are actually trying to verify.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...