PHP boolean's



Can anyone confirm if in PHP 0 = FALSE and anything else if TRUE?

Or is it more 0 = FALSE and 1 = TRUE?

One of the reasons I ask is that if I do;

//$count is an incrementing value starting from 0 in a loop
if($count % 2)
{
//do something
}

This works fine, but if I do:
if(!$count % 2)
{
//do something
}

It doesn't work. Should it not just be a boolean comparison? Why do I
need to do this to get my FALSE?

if($count % 2 === 0)
{

}
.



Relevant Pages

  • Re: Efficiency questions: combined ifs and looping 4 times
    ... Choice of algorithm always has a far bigger impact in performance than ... Use sizeof before the loop, store the result in a var and use ... speaks well of PHP. ... your order of complexity analysis is off. ...
    (comp.lang.php)
  • Re: PHP [win32] & CLI Testers needed.
    ... written, lets just say to create shell emulation for now, and have ... My previous attempts to create the source below, ended with the loop ... finally resolve any issues due to this problem in PHP compatibility. ... Debug Warning: testforLinuxUser.php line 24 - stream_select: supplied argument is not a valid stream resource ...
    (php.general)
  • Re: file level metaprogramming
    ... With defun-to-file, I solved this problem in a minute. ... Those are just more reasons to:) ... Iterate is much more useful than loop. ... I recommend using my fork (in fact with only a small patch), ...
    (comp.lang.lisp)
  • Re: Parsing PHP with HTML file extension
    ... than ".php" for various reasons (although even better would be no file ... extension at all in the URLs). ... bookmarks, SEO credit, search engine- and other outside links intact & ... apathetic about whether the underlying bits are html, php, python, perl, ...
    (comp.lang.php)
  • Can anyone explain PHP slowing down please ?
    ... I'm using PHP 5 on Win-98 command line ... I'm processing a large csv file and when I loop through it I can process ... I dont do any file seeking or open and closing of files during the loop. ...
    (comp.lang.php)