Главная /
PHP: ООП и классы /
Сценарий PHP содержит следующий код: <?php class cFoo implements Iterator { public $Contents = array(); public function __construct($_Contents) { $this->Contents = $_Contents; } public function rewind() { reset($this->Contents); $this->Content
Сценарий PHP содержит следующий код:
<?php
class cFoo implements Iterator
{
public $Contents = array();
public function __construct($_Contents) { $this->Contents = $_Contents; }
public function rewind() { reset($this->Contents); $this->Contents[0]+="1"; }
public function current() { return current($this->Contents); }
public function key() { return key($this->Contents);}
public function next() { return next($this->Contents); }
public function valid() { $this->Contents[key($this->Contents)].="2";
return ($this->current() !== false); }
}
$foo = new cFoo(array("1","2","3","4")); $temp = 0;
foreach ($foo as $bar) { $temp++; }
echo $foo->Contents[0];
?>
Укажите результат выполнения сценария:
вопрос
Правильный ответ:
1
12
22
212
cценарий не будет выполнен, т.к. код содержит ошибки
Сложность вопроса
52
Сложность курса: PHP: ООП и классы
88
Оценить вопрос
Комментарии:
Аноним
Экзамен сдал на отлично. Спасибо за халяуву
07 апр 2020
Аноним
Я завалил зачёт, за что я не углядел данный сайт с всеми ответами по тестам интуит до того как забрали в армию
22 янв 2018
Другие ответы на вопросы из темы программирование интуит.
- # Для разрешения доступа к полю из класса, который это поле содержит, или из классов-потомков используется модификатор
- # Сценарий PHP содержит следующий код: <?php class cBar1 { public $publ = "открытый"; public $prot = "защищенный"; private function priv(){return "закрытый";} } class cBar2 extends cBar1 { function View() { echo $this->publ." ".$this->prot." ".$this->priv(); } } $foo = new cBar2; $foo->View(); ?> Укажите результат выполнения сценария:
- # Сценарий PHP содержит следующий код: <?php class cBase { protected function f() {echo "base";} public function g() {$this->f();} } class cDerivative extends cBase { function g() {echo "derivative";} } $der = new cDerivative; $der->g(); ?> Укажите результат выполнения сценария:
- # Если во внешней области видимости происходит попытка получить значение private поля класса, метод __get() которого определен:
- # Сценарий PHP содержит следующий код: <?php class cFoo implements Iterator { public $Contents = array(); public function __construct($_Contents) { $this->Contents = $_Contents; } public function rewind() { reset($this->Contents); $this->Contents[0].="1"; } public function current() { $this->Contents[key($this->Contents)].="2"; return current($this->Contents); } public function key() { return key($this->Contents); } public function next() { return next($this->Contents); } public function valid() { return ($this->current() !== false); } } $foo = new cFoo(array("a","b","c","d")); $temp = 0; foreach ($foo as $bar) { $temp++; } echo $foo->Contents[0]; ?> Укажите результат выполнения сценария: