Fix syntax to use equal to operator instead of assignment operator. (#24467)
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:
committed by
Manish Giri
parent
e99601d263
commit
022ffb21b2
@ -7,25 +7,25 @@ Conditionals in PHP are written using the `if`, `elseif`, `else` syntax. Using c
|
||||
### If
|
||||
```PHP
|
||||
<?php
|
||||
if ($_GET['name'] = "freecodecamp"){
|
||||
if ($_GET['name'] == "freecodecamp"){
|
||||
echo "You viewed the freeCodeCamp Page!";
|
||||
}
|
||||
```
|
||||
### Elseif
|
||||
```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
|
||||
```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!";
|
||||
|
Reference in New Issue
Block a user