문제

Why does the variable change within this if statment

$userid = 500;
echo "User ID" . $userid; // Outputs 500

if($userid=362) {   
  echo "User ID" . $userid . "x"; // Outputs 362
}

올바른 솔루션이 없습니다

다른 팁

= is the assignment operator. So your if statement is assigning the value of 362 to $userid. What you want to use is == which is a comparison operator:

if($userid=362) {   

should be

if($userid==362) {   
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top