Files
freeCodeCamp/guide/russian/php/conditionals/index.md
Dhiraj Kanchan 54ac1ea02e Fix if statement to use equal to operator instead of assignment operator. (#24523)
Fix if statement to use Double equals (==)  instead of Single equal  (=) which would overwrite the value of $_GET['name'] variable.
2018-11-28 21:32:38 +04:00

49 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Conditionals
localeTitle: Conditionals
---
## Conditionals
Условные в PHP написаны с использованием синтаксиса `if` , `elseif` , `else` . Использование условных выражений позволяет выполнять различные действия в зависимости от разных входов и значений, предоставляемых на странице во время выполнения. В PHP условные обозначения часто называются структурами управления.
### Если
```PHP
<?php
if ($_GET['name'] == "freecodecamp"){
echo "You viewed the freeCodeCamp Page!";
}
```
### Elseif
```PHP
<?php
if ($_GET['name'] == "freecodecamp"){
echo "You viewed the freeCodeCamp Page!";
} elseif ($_GET['name'] == "freecodecampguide"){
echo "You viewed the freeCodeCamp Guide Page!";
}
```
### еще
```PHP
<?php
if ($_GET['name'] == "freecodecamp"){
echo "You viewed the freeCodeCamp Page!";
} elseif ($_GET['name'] == "freecodecampguide"){
echo "You viewed the freeCodeCamp Guide Page!";
} else {
echo "You viewed a page that does not exist yet!";
}
```
### Заметка
В случаях, когда у вас есть много возможных условий, вы можете использовать [инструкцию Switch](/php/switch) .
#### Дополнительная информация:
* [Руководство по управлению структурой php.net](https://secure.php.net/manual/en/control-structures.elseif.php)