I am learning PHP and my echo
is echoing wrong data.
$user_post=4;
if($user_post=5){
echo "User has 5 posts.";
}else{
echo "Cannot continue! Not enough posts: $user_post"; die();
}
Thank you for help.
I am learning PHP and my echo
is echoing wrong data.
$user_post=4;
if($user_post=5){
echo "User has 5 posts.";
}else{
echo "Cannot continue! Not enough posts: $user_post"; die();
}
Thank you for help.
your if is not correct. You must use ==, not = to check if somethng equals in PHP.
if($user_post==5)
You have to use comparison operator: equal ==
(same value) or identical ===
(same value and same type).
You can explore php manual for learning http://php.net/manual/en/language.operators.comparison.php
if($user_post=5)
this is assignment operator each time it will assing 5 to $user_post varibale change your operator to
if($user_post == 5)
or
if($user_post ==== 5)
The difference is frist one will check value only and 2nd one will check its type I hope it will help you