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

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-08-11 05:13:30 +05:30
committed by Randell Dawson
parent a0cdec9ab1
commit 85b5707305

View File

@ -10,7 +10,7 @@ Los condicionales en PHP se escriben usando la sintaxis `if` , `elseif` , `else`
```PHP ```PHP
<?php <?php
if ($_GET['name'] = "freecodecamp"){ if ($_GET['name'] == "freecodecamp"){
echo "You viewed the freeCodeCamp Page!"; echo "You viewed the freeCodeCamp Page!";
} }
``` ```
@ -19,9 +19,9 @@ Los condicionales en PHP se escriben usando la sintaxis `if` , `elseif` , `else`
```PHP ```PHP
<?php <?php
if ($_GET['name'] = "freecodecamp"){ if ($_GET['name'] == "freecodecamp"){
echo "You viewed the freeCodeCamp Page!"; echo "You viewed the freeCodeCamp Page!";
} elseif ($_GET['name'] = "freecodecampguide"){ } elseif ($_GET['name'] == "freecodecampguide"){
echo "You viewed the freeCodeCamp Guide Page!"; echo "You viewed the freeCodeCamp Guide Page!";
} }
``` ```
@ -30,9 +30,9 @@ Los condicionales en PHP se escriben usando la sintaxis `if` , `elseif` , `else`
```PHP ```PHP
<?php <?php
if ($_GET['name'] = "freecodecamp"){ if ($_GET['name'] == "freecodecamp"){
echo "You viewed the freeCodeCamp Page!"; echo "You viewed the freeCodeCamp Page!";
} elseif ($_GET['name'] = "freecodecampguide"){ } elseif ($_GET['name'] == "freecodecampguide"){
echo "You viewed the freeCodeCamp Guide Page!"; echo "You viewed the freeCodeCamp Guide Page!";
} else { } else {
echo "You viewed a page that does not exist yet!"; echo "You viewed a page that does not exist yet!";