Главная /
PHP: ООП и классы /
Сценарий PHP содержит следующий код: <?php class cFoo implements ArrayAccess { protected $Contents = array(); public $OperationCount = 0; public function offsetExists($_offset) { return isset($this->Contents[$_offset]); } public function offsetGet($
Сценарий PHP содержит следующий код:
<?php
class cFoo implements ArrayAccess
{
protected $Contents = array(); public $OperationCount = 0;
public function offsetExists($_offset) { return isset($this->Contents[$_offset]); }
public function offsetGet($_offset) { $this->OperationCount++;
return $this->Contents[$_offset]; }
public function offsetSet($_offset,$_value){$this->Contents[$_offset] = $_value;}
public function offsetUnset($_offset) { unset($this->Contents[$_offset]); }
}
$foo = new cFoo;
$foo["bar1"] = "значение1"; $foo["bar2"] .= "значение2";
echo $foo->OperationCount;
?>
Укажите результат выполнения сценария:
вопрос
Правильный ответ:
3
2
1
пустая строка
cценарий не будет выполнен, т.к. код содержит ошибки
Сложность вопроса
87
Сложность курса: PHP: ООП и классы
88
Оценить вопрос
Комментарии:
Аноним
Зачёт прошёл. Лечу отмечать отмечать зачёт по тестам
30 июн 2017
Другие ответы на вопросы из темы программирование интуит.
- # Для разрешения доступа к полю из любой области видимости используется модификатор
- # Сценарий PHP содержит следующий код: <?php class cFoo { protected function GetProtected(){echo "защищенный ";} private function GetPrivate(){echo "закрытый ";} function GetAll(){$this->GetProtected();$this->GetPrivate();} } $foo = new cFoo(); $foo->GetAll();$foo->GetPrivate(); ?> Укажите результат выполнения сценария:
- # Сценарий PHP содержит следующий код: <?php class cBar1 { private $_public = "открытый"; public $_protected = "защищенный"; protected function _private(){return "закрытый";} } class cBar2 extends cBar1 { function View(){echo $this->_public." ".$this->_protected." ".$this->_private(); } } $foo = new cBar2; $foo->View(); ?> Укажите результат выполнения сценария:
- # Сценарий PHP содержит следующий код: <?php abstract class cBase { protected $Data; function __construct($_Data){$this->Data = $_Data;} abstract function ShowData(); } class cDerivative1 extends cBase { function ShowData(){return $this->Data."-";} } class cDerivative2 extends cBase { function ShowData(){return $this->Data."0";} } $foo = new cDerivative1(1); $bar = new cDerivative2(7); echo $foo->ShowData().$bar->ShowData().$foo->ShowData().$bar->ShowData(); ?> Укажите результат выполнения сценария:
- # Интерфейс в PHP объявляется с помощью ключевого слова: