Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

boolean flag not working

Status
Not open for further replies.

Griffyn

Programmer
Jul 11, 2002
1,077
AU
Hi all,

I'm learning as I go with PHP, and I can't figure out why my boolean code isn't working:
Code:
$backflag == false;
$roomspecs = explode ( '/', $roomdetail[1] );
foreach ( $roomspecs as $roomspec ) {
  if ( strtolower ( substr ( $roomspec, 0, 1 ) ) == 'c' ) {
    $backflag == true;
    $return == 'x';
    break;
  }
}
if ( !$backflag ) {
  $return == 'y';
}
The problem is that my $return var is getting set with either 'y' or 'xy', when it should only be 'x' or 'y'. I'm clearly doing something fundamentally wrong. What is it?
 
argh. Ok, I'm messing up my assigns (=) and my comparisons (==). Easy to fix. Used to Delphi, where it figures out both by just using (=).
 
Correct, for comparisons its == or even ===. For assignments its just =.





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Griffyn said:
Used to Delphi, where it figures out both by just using (=).
Actually, Delphi uses := for assignment and = for comparisons.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Have a coffee on me! ;-)

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top