Results 1 to 2 of 2

Thread: string comparing in cgi

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Perth, Western Australia
    Posts
    108
    common error... i do it all the time. There are different comparators for strings and numberical data. "==" is numerical and you want to compare strings so you should use eq.
    ie..

    $tmpstr=substr($temp_file,-4,4);
    if ($tmpstr eq ".htm")
    {
    print "True: $temp_file ($tmpstr)<BR>\n";
    }

    the other operators like this are
    Numerical - String - Use
    == - eq - is equal to
    <> - ne - is not equal to
    > - ge - is greater than
    < - le - is less than

    that is the basic ones there are others like ++ and -- but you wouldnt need to use them now.

  2. #2
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    thanks very much for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width