Introduction to the usage of PHP string comparison functions strcmp() and strcasecmp()

WBOY
Release: 2016-07-25 08:59:18
Original
1016 people have browsed it
  1. $a = "joe";
  2. $b = "jerry";
  3. if ($a != $b)
  4. {
  5. echo "not equal";
  6. }
  7. else
  8. {
  9. echo "Equal";
  10. }
  11. ?>
Copy code

If you use !==, === to compare, the types of the two objects must be strictly equal to return true; otherwise, use ==, != will automatically convert the string into the corresponding type for comparison.

  1. echo strnatcmp("10.gif", "5.gif"); // Return 1 (>0)
  2. echo strnatcasecmp("10.gif", "5.gif "); // Return 1 (>0)
  3. ?>
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template