note 80305 deleted from control-structures.if by cmb
| From: | cmb@php.net | Date: | Fri, 02 Oct 2020 13:00:19 +0000 |
| Subject: | note 80305 deleted from control-structures.if by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215523@lists.php.net to get a copy of this message | ||
Note Submitter: redrobinuk at aol dot com
----
This is aimed at PHP beginners but many of us do this Ocasionally...
When writing an if statement that compares two values, remember not to use a single = statement.
eg:
<?php
if ($a = $b)
{
print("something");
}
?>
This will assign $a the value $b and output the statement.
To see if $a is exactly equal to $b (value not type) It should be:
<?php
if ($a == $b)
{
print("something");
}
?>
Simple stuff but it can cause havok deep in classes/functions etc...