База ответов ИНТУИТ

Web-программирование на PHP 5.2

<<- Назад к вопросам

Каким будет результат выполнения следующего кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php      $str = "123 234 345 456 567";     $result = preg_match('/\d(\d)\d/', $str, $found);      echo "Matches: $result <br>";     print_r($found);  ?> </body> </html>     

(Отметьте один правильный вариант ответа.)

Варианты ответа
в браузере получим: Matches: 1, Array ( [0] => 123 234 [1] => 2 [2] => 3 )
в браузере получим: Matches: 1, Array( [0] => 234 [1] => 3 )
в браузере получим: Matches: 1, Array ( [0] => 123 234 345 456 [1] => 2 [2] => 3 [3] => 4 [4] => 5 )
в браузере получим: Matches: 1, Array( [0] => 456 [1] => 5 )
в браузере получим: Matches: 1, Array ( [0] => 123 234 345 456 567 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
в браузере получим: Matches: 1, Array( [0] => 345 [1] => 4 )
в браузере получим: Matches: 1, Array( [0] => 567 [1] => 6 )
в браузере получим: Matches: 1, Array ( [0] => 123 234 345 [1] => 2 [2] => 3 [3] => 4 )
в браузере получим: Matches: 1, Array( [0] => 123 [1] => 2 )(Верный ответ)
Похожие вопросы
Что вернет функция print_r() в результате выполнения следующего кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php     $subject = "Мой телефон - 211-22-33";    $pattern = '/([2-8]{1}[0-9]{2})-([0-9]{2}-[0-9]{2})/';    echo preg_match($pattern, $subject, $matches);     print_r($matches);   ?> </body> </html>     
Каким будет результат выполнения следующего кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php      $pattern = "/(\w+)\s(\w+)\s(\w+)/";     $subject = "Александр Иванович Привалов";	      $matches = preg_replace($pattern,'\3, \1 \2',$subject);      echo $matches;  ?> </body> </html>     
Каким будет результат выполнения следующего кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php      $subject = "12345-1234";     $pattern = '/\d{5}-d{4}/';     echo preg_match($pattern, $subject);   ?> </body> </html>     
Каким будет результат выполнения следующего кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php      $subject = "12212345678 - 1234";     $pattern = '/^\d{5}$/';     echo preg_match($pattern, $subject);   ?> </body> </html>     
Каким будет результат выполнения следующего кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php      $subject = "12212345 - 1234";     $pattern = '/^\d{5}/';     echo preg_match($pattern, $subject);   ?> </body> </html>     
Каким будет результат выполнения следующего кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php      $var = "Двадцать пять";     echo "Оригинал: $var <hr/>\n";      echo substr_replace($var, "25", 0)."<br/>\n";   ?> </body> </html>     
Каким будет результат выполнения следующего кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php      $var = "Строка букв";     echo "Оригинал: $var <hr/>\n";      echo substr_replace($var, "цифр", 7)."<br/>\n";   ?> </body> </html>     
Каким будет результат выполнения следующего кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php      $var = "Строка состоит из 29 символов";     echo substr_replace($var, " ", 18, 2)."<br/>\n";   ?> </body> </html>     
Каким будет результат выполнения следующего PHP-кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body>   <?php     echo phpversion();  ?> </body> </html>     
Каким будет результат выполнения следующего PHP-кода:
<html> <head>   <title>Example from intuit.ru</title> </head>  <body> 	 <?php var_dump(pow(2,8));  echo "<br>"; echo pow(-1,20)."<br>";  echo pow(0, 0)."<br>";  echo pow(-1, 5.5)."<br>";?> </body> </html>