Exam 200-710 All QuestionsBrowse all questions from this exam
Question 18

What is the output of the following code?

    Correct Answer: B

    The code demonstrates object-oriented programming in PHP. The 'Test' class defines a public variable 'var' initialized to 1. An instance of the Test class is then created and passed to the 'addMe' function. Inside the 'addMe' function, the 'var' property of the passed object is incremented by 1. As a result, after calling 'addMe', the 'var' property of the 'Test' instance 't' becomes 2. Hence, when 'echo $t->var;' is executed, it outputs 2.

Discussion
ZhukovPeterOption: B

Confirm, answer is B. You can play this program in any PHP online playgrounds. Program: class Test { public $var = 1; } function addMe(Test $t){ $t->var++; } $t = new Test(); addMe($t); echo $t->var; output: 2

bareaOption: B

The correct answer is B

[Removed]Option: B

The correct answer is B : 2

thuanptOption: B

The correct answer is B : 2

Andres_Espinosa1Option: B

confirmado , se realiza el ejercicio y la respuesta correcta es 2