# PHP == or ===, why is my string equal to zero

Source: https://coursesweb.net/forum/t/php-or-why-is-my-string-equal-to-zero/
Site: CoursesWeb Forum, category PHP Forms, Sessions and Basics
Published: 2026-12-05. Updated: 2026-12-06. Replies: 2.

## Question by Mpho N., 2026-12-05

Our lecturer says "always use ===" but never says why, so I tested it. On my laptop (PHP 8.3):

```php
var_dump("abc" == 0);   // bool(false)
var_dump("1" == "01");  // bool(true)
var_dump("10" == "1e1"); // bool(true)
var_dump(null == false); // bool(true)
```

My classmate runs an old XAMPP with PHP 7.4 and he says the first line gives true for him. So the same code gives different answers on different versions? That seems mad. Which rules does == actually follow, and is === really always the right choice, even when I compare a number from a form with a number in my code?

## Reply 1 by Kaveh S., 2026-12-05

JS has the same problem, == does type juggling and === doesn't. Rule in bootcamp: === unless you have a reason.

## Reply 2 by Lin W., 2026-12-06

This bit me on the restaurant site. An order status of "0" in the database matched an empty string check somewhere. I still don't fully understand why, so following this.

---
Cite as: CoursesWeb Forum, "PHP == or ===, why is my string equal to zero", https://coursesweb.net/forum/t/php-or-why-is-my-string-equal-to-zero/, accessed 2026-12-06.
