PHP === and == operators
by
·
In PHP syntax the == operator (two equality signs) returns true if the compared values are equal, even if they are in different types (for example, 7 == “7” is true).
The === operator (three equality signs) returns true only if the compared values are absolutely equal, i.e. they have equivalent types as well (e.g. 7 === “7” returns false but 7 === 7 returns true).
Another example, p == 0 is true for p being 0, but also for p being “0” (a string containing the character 0).
p === 0 is true only when p is 0.
Note that Javascript too provides the === operator.
Related:
- Learn PHP reading and searching a free PHP Reference book
- Edit PHP, HTML, CSS, JS, with Codelobster PHP Edition
- Host websites featuring PHP, Python, Perl and much more, with Apache HTTP Server
- QuickPHP lightweight standalone PHP web server to test and debug scripts
- Run Apache, MySQL, PHP on Windows, even along with IIS, using XAMPP or WampServer
- Setup on your Windows PC, even along with IIS, PHP, Apache, MySQL, PhpMyAdmin, Xdebug, with EasyPHP Installer
- Identify the PHP version of your web site easily
Comments are closed, but you can
send email
Tags: JavaScriptphpphp equalityphp operators