11. What will the following script output?

<?php
class my_class
{
var $my_var;
function _my_class ($value)
{
$this->my_var = $value;
}
}
$a = new my_class (10);
echo $a->my_var;
?>


Вариант ответа 1 - A) 10

Вариант ответа 2 - B) Null

Вариант ответа 3 - C) Empty

Вариант ответа 4 - D) Nothing

Вариант ответа 5 - E) An error


Комментарий: The right answer here is D—the script won’t output anything because my_class::_my_class() is not a valid constructor (did you notice the underscore at the beginning of the method name?). You might think that this is nothing but a trick question designed to see how much attention you’re paying during the exam… and you’re right. If you think about it, though, you’ll probably agree with us that many bugs occur because of misplaced haracters. Therefore, this question is really designed to gauge your ability to catch mistakes in OOP code, rather than just to trick you.

Комментарии

Имя пользователяТекст комментарияВведите код