Because you are using the == (similarity) operator and PHP is coercing the string to an int.
To resolve it use the === (equality) operator, which checks not only if the value is the same, but also if the data type is the same, so “123” string and 123 int won’t be considered equal.
More Related Contents:
- How to remove array index from json object while convert array to jsonobject php? [closed]
- Get first day of current month in php [closed]
- Can PHP PDO Statements accept the table or column name as parameter?
- How to include a PHP variable inside a MySQL statement
- How do you connect to multiple MySQL databases on a single webpage?
- Reading/Writing a MS Word file in PHP
- Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘username’@’localhost’ (using password: YES)
- Achieve hierarchy, Parent/Child Relationship in an effective and easy way
- Why is PHP printing my number in scientific notation, when I specified it as .000021?
- Build SELECT query with dynamic number of LIKE conditions as a mysqli prepared statement
- PHP compare time
- CodeIgniter: “The filetype you are attempting to upload is not allowed.”
- Session lost when switching from HTTP to HTTPS in PHP
- Remove style attribute from HTML tags
- Ajax LARAVEL 419 POST error
- Match a^n b^n c^n (e.g. “aaabbbccc”) using regular expressions (PCRE)
- How to delete a file via PHP?
- Laravel 5.2 $errors not appearing in Blade
- Redirect with CodeIgniter
- How to create a PSR-4 autoloader for my project?
- Convert JPG/GIF image to PNG in PHP?
- Get Updated Value in MySQL instead of affected rows
- Parsing URL query in PHP [duplicate]
- How Can I Set the Default Value of a Timestamp Column to the Current Timestamp with Laravel Migrations?
- Notice: Undefined index when trying to increment an associative array in PHP
- How do you explain the result for a new \DateTime(‘0000-00-00 00:00:00’)?
- Do PHP PDO prepared statements need to be escaped?
- Regex / DOMDocument – match and replace text not in a link
- remove new line characters from txt file using php
- PHP: How to check if a date is today, yesterday or tomorrow