Skip to content

Commit e761dc8

Browse files
authored
Merge pull request #360 from hexlet-basics/new
new structure
2 parents 5023403 + cf21faf commit e761dc8

File tree

675 files changed

+12949
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

675 files changed

+12949
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copy the exact code from the instructions into the editor and run it by clicking «Run».
2+
3+
```php
4+
<?php
5+
6+
print_r('Hello, World!');
7+
```
8+
9+
Note: If you write `heLLo, woRld!` instead of `Hello, World!`, it will be considered different text because upper and lower case letters are different characters. _Case is important!_ This rule affects almost everything in coding, so make sure you get used to paying close attention to the case at all times.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
As is our tradition, we'll begin by writing the 'Hello, World!' program. The program will print the following text:
2+
3+
<pre class='hexlet-basics-output'>
4+
Hello, World!
5+
</pre>
6+
7+
Output to the screen is done with a special command `echo`, followed by a single or double-quoted string to be output. Be sure to put a semicolon at the end.
8+
9+
```php
10+
<?php
11+
12+
echo 'Hello, World!'; // => Hello, World!
13+
```
14+
15+
https://replit.com/@hexlet/php-basics-hello-world-echo
16+
17+
There are other ways to display a string on the screen. For example, you can use the function (a concept we will get to know later) `print_r()`. In this case, the string is entered in parentheses immediately after the function name. You also need to put `;` at the end.
18+
19+
```php
20+
<?php
21+
22+
print_r('Hello, World!');
23+
```
24+
25+
https://replit.com/@hexlet/php-basics-hello-world-printr
26+
27+
In simple situations, there's no difference between these constructions. You can use either one method of output or the other. In more complex cases, where you want to display not just numbers or strings, but, for example, arrays, `echo` won't be able to do this, but `print_r()` will display everything.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: Hello, World!
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Escribe en el editor el código del ejercicio carácter por carácter y luego haz clic en "Verificar".
2+
3+
```php
4+
<?php
5+
6+
print_r('Hello, World!');
7+
```
8+
9+
¡Atención! Si escribes `heLLo, woRld!` en lugar de `Hello, World!`, se considerará un texto diferente, ya que las mayúsculas y minúsculas son caracteres distintos. El tamaño de las letras se llama _mayúsculas_ y _minúsculas_, y se dice: ¡_las mayúsculas importan_! Esto se aplica a casi todo el código, así que acostúmbrate a prestar siempre atención a las mayúsculas y minúsculas.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
En esta lección vamos a escribir nuestro primer programa. Aprenderemos qué comandos se necesitan y qué etiquetas se deben utilizar para que el programa que ejecuta el código lo interprete correctamente. También aprenderemos por qué son necesarios los comentarios en el código.
2+
3+
## Cómo escribir un programa simple
4+
5+
Hay dos formas de escribir un programa y mostrar el resultado en la pantalla:
6+
7+
* Usando el comando `echo`
8+
* Usando la función `print_r()`
9+
10+
Veamos cada una en detalle.
11+
12+
### Escribir un programa usando `echo`
13+
14+
Vamos a escribir un programa que muestre "¡Hola, Mundo!" en la pantalla:
15+
16+
```php
17+
<?php
18+
19+
echo '¡Hola, Mundo!';
20+
// => ¡Hola, Mundo!
21+
```
22+
23+
https://replit.com/@hexlet/php-basics-hello-world-echo
24+
25+
La salida en la pantalla se realiza utilizando el comando especial `echo`. Después de él, se especifica la cadena a mostrar entre comillas simples. Al final, es importante colocar un punto y coma.
26+
27+
Para mayor comodidad, mostraremos el resultado de la ejecución del código de esta manera: `=> RESULTADO`.
28+
29+
### Escribir un programa usando `print_r()`
30+
31+
Otra forma de mostrar una cadena en la pantalla es utilizando la función `print_r()`:
32+
33+
```php
34+
<?php
35+
36+
print_r('¡Hola, Mundo!');
37+
// => ¡Hola, Mundo!
38+
```
39+
40+
https://replit.com/@hexlet/php-basics-hello-world-printr
41+
42+
En este caso, la cadena se especifica entre paréntesis justo después del nombre de la función. Al final, también es necesario colocar un punto y coma.
43+
44+
En situaciones simples, no hay diferencia entre estas dos construcciones. Puedes usar cualquier método. Sin embargo, cuando necesitas mostrar en la pantalla algo más que números o cadenas, por ejemplo, matrices, `echo` no podrá hacerlo, pero `print_r()` sí.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: ¡Hola, Mundo!
2+
tips:
3+
- >
4+
[Un poco sobre 'Hello,
5+
World!'](https://codica.la/blog/mi-gente-me-entiende-la-historia-de-la-frase-hello-world-y-sus-analogos)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Наберите в редакторе код из задания символ в символ и нажмите «Проверить».
2+
3+
```php
4+
<?php
5+
6+
print_r('Hello, World!');
7+
```
8+
9+
Внимание: если вы напишете `heLLo, woRld!` вместо `Hello, World!`, то это будет считаться другим текстом, потому что заглавные и строчные буквы — разные символы. Размер буквы называют _регистром_ и говорят: _регистр — важен!_ Это касается почти всего в коде, поэтому привыкайте всегда обращать внимание на регистр.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
В этом уроке мы сразу напишем первую программу. Мы узнаем, какие команды понадобятся для этого и какие теги нужно использовать, чтобы программа, которая выполняет код, восприняла его. Также узнаем, зачем в коде нужны комментарии.
2+
3+
## Как написать простую программу
4+
5+
Чтобы написать программу и вывести результат на экран, используют два способа:
6+
7+
* Через команду `echo`
8+
* Через команду `print_r()`
9+
10+
Разберем каждую подробнее.
11+
12+
### Пишем программу через `echo`
13+
14+
Напишем программу «Hello, World!». Она будет выводить на экран текст:
15+
16+
```php
17+
<?php
18+
19+
echo 'Hello, World!';
20+
// => Hello, World!
21+
```
22+
23+
https://replit.com/@hexlet/php-basics-hello-world-echo
24+
25+
Вывод на экран выполняется с помощью специальной команды `echo`. После нее в одиночных кавычках указывается строка для вывода. В конце обязательно ставим точку с запятой.
26+
27+
Для удобства мы будем показывать результат запуска строк кода так: `=> РЕЗУЛЬТАТ`.
28+
29+
### Пишем программу через `print_r()`
30+
31+
Другой способ вывести строку на экран — функция `print_r()`:
32+
33+
```php
34+
<?php
35+
36+
print_r('Hello, World!');
37+
// => Hello, World!
38+
```
39+
40+
https://replit.com/@hexlet/php-basics-hello-world-printr
41+
42+
В этом случае строка указывается в скобках сразу после имени функции. В конце также нужно ставить `;`.
43+
44+
В простых ситуациях между этими конструкциями нет разницы. Можно использовать любой способ. А там, где на экран нужно выводить не просто числа или строки, а, например, массивы, `echo` не сможет этого сделать, а `print_r()` все выведет.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: Привет, Мир!
2+
tips:
3+
- >
4+
[Немного о 'Hello,
5+
World!'](https://ru.hexlet.io/blog/posts/moy-chelovek-menya-ponimaet-istoriya-frazy-hello-world-i-ee-analogov)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Type the code from the example, and put the `<?php` tag at the beginning:
2+
3+
```php
4+
<?php
5+
6+
print_r('King in the North!');
7+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PHP is probably the only language in which you can't start writing code right away. Such code will be perceived by the interpreter (the program executing the code) as plain text. Any PHP code should be wrapped in a `<?php ?>` construct.
2+
3+
`<?php` is the opening tag and `?>` is the closing tag. PHP allows you to omit the closing part `?>`. And the PSR-12 code manual doesn't let you include it at all.

modules/10-basics/20-tags/en/data.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: Tags
2+
tips:
3+
- '[Basic Code Writing Standard (PSR-1)](https://www.php-fig.org/psr/psr-1/)'
4+
- '[Code Design Guide (PSR-12)](https://www.php-fig.org/psr/psr-12/)'
5+
definitions:
6+
- name: Interpreter
7+
description: a program that executes code written in a programming language.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Escriba el código del ejemplo y coloque la etiqueta `<?php` al principio:
2+
3+
```php
4+
<?php
5+
6+
print_r('King in the North!');
7+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## ¿Por qué usar etiquetas?
2+
3+
Para que el **intérprete** - el programa que ejecuta el código - lo interprete como código y no como texto normal, es necesario envolver cualquier código en PHP con la construcción `<?php ?>`. Esta es una característica de este lenguaje de programación.
4+
5+
`<?php` es la etiqueta de apertura y `?>` es la etiqueta de cierre. PHP permite no especificar la parte de cierre `?>`. Y la guía de estilo de código PSR-12 prohíbe su especificación.

modules/10-basics/20-tags/es/data.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Etiquetas
2+
tips:
3+
- '[PSR-1: Estándar básico de codificación](https://www.php-fig.org/psr/psr-1/)'
4+
- >-
5+
[PSR-12: Guía de estilo de
6+
codificación](https://www.php-fig.org/psr/psr-12/)
7+
definitions:
8+
- name: Intérprete
9+
description: programa que ejecuta el código escrito en un lenguaje de programación.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Наберите код из примера, поставьте в начале тег `<?php`:
2+
3+
```php
4+
<?php
5+
6+
print_r('King in the North!');
7+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Зачем использовать теги
2+
3+
Чтобы **интерпретатор** — программа, которая выполняет код, — восприняла его не как обычный текст, любой код на PHP нужно оборачивать в конструкцию `<?php ?>`. Это особенность данного языка программирования.
4+
5+
`<?php` — это открывающий тег, а `?>` — закрывающий тег. PHP позволяет не указывать закрывающую часть `?>`. А руководство по оформлению кода PSR-12 запрещает ее указывать.

modules/10-basics/20-tags/ru/data.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Теги
2+
tips:
3+
- >-
4+
[Базовый стандарт написания кода
5+
(PSR-1)](https://www.php-fig.org/psr/psr-1/)
6+
- >-
7+
[Руководство по оформлению кода
8+
(PSR-12)](https://www.php-fig.org/psr/psr-12/)
9+
definitions:
10+
- name: Интерпретатор
11+
description: программа, выполняющая код, написанный на языке программирования.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Create a one-line comment with the text: `You know nothing, Jon Snow!`.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Almost every programming language allows you to add comments to your code. This is text that isn't part of the program and is needed for programmers to make notes. They help explain how the code works, what errors need to be corrected, or what not to forget to add later.
3+
4+
Comments in PHP come in two flavors:
5+
6+
## Single line comments
7+
8+
_Single line comments start with `//`. Any text can go after these characters, the whole line will be left alone when the program is run.
9+
10+
A comment can take up a whole line. Or you can create several comments if one line isn't enough:
11+
12+
```php
13+
<?php
14+
15+
// For Winterfell!
16+
// For Lanisters!
17+
```
18+
19+
Or it can go after code on the same line:
20+
21+
```php
22+
<?php
23+
print_r('I am the King'); // For Lannisters!
24+
```
25+
26+
## Multi-line comments
27+
28+
_Multiline comments_ start with `/*` and end with `*/`. Each line between them must begin with a `*`.
29+
30+
```php
31+
<?php
32+
/*
33+
* The night is dark and
34+
* full of terrors.
35+
*/
36+
print_r('I am the King');
37+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Comments
2+
tips: []
3+
definitions:
4+
- name: Comment
5+
description: >
6+
text in program code that doesn't affect functionality, and is added by
7+
programmers for themselves and their colleagues.
8+
9+
10+
`// single-line comment`
11+
12+
13+
```
14+
15+
/*
16+
17+
* multiline comment
18+
19+
* multiline comment
20+
21+
*/
22+
23+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Crea un comentario de una línea con el texto: `¡No sabes nada, Jon Snow!`.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## ¿Para qué sirven los comentarios?
2+
3+
Además del código en los archivos de código fuente, puede haber comentarios. Este texto no es parte del programa. Es útil para los programadores como notas. Con ellos se agregan explicaciones, por ejemplo, cómo funciona el código, qué errores corregir o qué agregar más tarde.
4+
5+
Los comentarios en PHP pueden ser de dos tipos:
6+
7+
* **Comentarios de una línea** - comienzan con `//`. Después de estos caracteres puede seguir cualquier texto, toda la línea no se analizará ni se ejecutará:
8+
9+
```php
10+
<?php
11+
12+
// ¡Por Winterfell!
13+
// ¡Por Lannisters!
14+
// El comentario puede estar en la línea después de algún código
15+
print_r('Soy el Rey'); // ¡Por Lannisters!
16+
```
17+
18+
* **Comentarios de varias líneas** - comienzan con `/*` y terminan en `*/`. Entre ellos, cada línea debe comenzar con el carácter `*`:
19+
20+
```php
21+
<?php
22+
/*
23+
* La noche es oscura y
24+
* está llena de terrores.
25+
*/
26+
print_r('Soy el Rey');
27+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Comentarios
2+
tips: []
3+
definitions:
4+
- name: Comentario
5+
description: >
6+
texto en el código del programa que no afecta la funcionalidad y se agrega
7+
por los programadores para ellos mismos y sus colegas.
8+
9+
10+
`// comentario de una línea`
11+
12+
13+
```
14+
15+
/*
16+
17+
* comentario de varias líneas
18+
19+
* comentario de varias líneas
20+
21+
*/
22+
23+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Создайте однострочный комментарий с текстом: `You know nothing, Jon Snow!`.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Зачем нужны комментарии
2+
3+
Кроме кода в файлах с исходным кодом могут находиться комментарии. Этот текст не является частью программы. Он нужен программистам для пометок. С их помощью добавляют пояснения, например, как работает код, какие ошибки нужно поправить или не забыть что-то позже добавить.
4+
5+
Комментарии в PHP бывают двух видов:
6+
7+
* **Однострочные комментарии** — начинаются с `//`. После этих символов может следовать любой текст, вся строка не будет анализироваться и исполняться:
8+
9+
```php
10+
<?php
11+
12+
// For Winterfell!
13+
// For Lanisters!
14+
// Комментарий может находиться на строке после какого-нибудь кода
15+
print_r('I am the King'); // For Lannisters!
16+
```
17+
18+
* **Многострочные комментарии** — начинаются с `/*` и заканчиваются на `*/`. Между ними каждая строка должна начинаться с символа `*`:
19+
20+
```php
21+
<?php
22+
/*
23+
* The night is dark and
24+
* full of terrors.
25+
*/
26+
print_r('I am the King');
27+
```

0 commit comments

Comments
 (0)