Fix if statement to use equal to operator instead of assignment operator. (#24522)

Fix if statement to use Double equals (==)  instead of Single equal  (=) which would overwrite the value of $_GET['name'] variable.
This commit is contained in:
Dhiraj Kanchan
2019-01-04 04:52:05 +11:00
committed by Jingyi Ding
parent 917955708a
commit 8b39e83e24

View File

@ -10,7 +10,7 @@ PHP中的条件语句使用`if` `elseif` `else`语法编写。使用条
```PHP
<?php
if ($_GET['name'] = "freecodecamp"){
if ($_GET['name'] == "freecodecamp"){
echo "You viewed the freeCodeCamp Page!";
}
```
@ -19,9 +19,9 @@ PHP中的条件语句使用`if` `elseif` `else`语法编写。使用条
```PHP
<?php
if ($_GET['name'] = "freecodecamp"){
if ($_GET['name'] == "freecodecamp"){
echo "You viewed the freeCodeCamp Page!";
} elseif ($_GET['name'] = "freecodecampguide"){
} elseif ($_GET['name'] == "freecodecampguide"){
echo "You viewed the freeCodeCamp Guide Page!";
}
```
@ -30,9 +30,9 @@ PHP中的条件语句使用`if` `elseif` `else`语法编写。使用条
```PHP
<?php
if ($_GET['name'] = "freecodecamp"){
if ($_GET['name'] == "freecodecamp"){
echo "You viewed the freeCodeCamp Page!";
} elseif ($_GET['name'] = "freecodecampguide"){
} elseif ($_GET['name'] == "freecodecampguide"){
echo "You viewed the freeCodeCamp Guide Page!";
} else {
echo "You viewed a page that does not exist yet!";
@ -45,4 +45,4 @@ PHP中的条件语句使用`if` `elseif` `else`语法编写。使用条
#### 更多信息:
* [php.net控制结构手册](https://secure.php.net/manual/en/control-structures.elseif.php)
* [php.net控制结构手册](https://secure.php.net/manual/en/control-structures.elseif.php)