$check = 'this is a string 111';
if ($check = 'this is a string') {
echo 'perfect match';
} else {
echo 'it did not match up';
}
But it returns perfect match everytime instead of it did not match up... I can not seem to get the string to match the case exactly it will only work if part of the string matches up.
If i try to complicate things a little using board code and regex patterns it becomes a nightmare.
if ($check = '/\[quote(.*?)\](.*?)\[\/quote\]/su') {
$spam['spam'] = true;
$spam['error'] .= 'Spam post quote.<br />';
}
So if the post only contained quote tags it would be considered spam and ditched but i can not seem to solve it perhaps my patterns are wrong.
You need to use ==
not just =
$check = 'this is a string 111';
if ($check == 'this is a string') {
echo 'perfect match';
} else {
echo 'it did not match up';
}
=
will assign the variable.
==
will do a loose comparison
===
will do a strict comparison
See comparison operators for more information.
For equality comparison you want the ==
operator. =
is assignment.
if ($check = 'this is a string') {
should be
if ($check == 'this is a string') {
Don't worry, we've all done it. I still do :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With