Nempak
Новичок
Привет! Понимаю что задача очень проста, но всё же мне нужна подсказка. Суть задачи:
Всё работает, выводит символ. Но проверка показывает ошибку
Oops, try again. Your printed output from rand() should be an integer.
- Use the editor to print a random number.
- Create a new variable $name and store your name in it.
- Then print a random character from your name. Use your knowledge ofstrlen(string), rand(min, max), andsubstr(string, start, length) to do this.
PHP:
<html>
<p>
<?php
// Use rand() to print a random number to the screen
$name = "Maxym";
// Создал переменную со своим именем.
?>
</p>
<p>
<?php
// Use your knowledge of strlen(), substr(), and rand() to
// print a random character from your name to the screen.
$name_len = strlen($name);
// в переменную $name_len записываю длину имени.
echo "<br>";
$rand_len = rand(0, $name_len);
//в переменную $rand_len записываю рандомное число от 0 до числа которое получил в $name_len
echo "<br>";
echo substr($name, $rand_len, 1);
// Вывожу символ имени.
?>
</p>
</html>
Oops, try again. Your printed output from rand() should be an integer.