200-710 Exam QuestionsBrowse all questions from this exam

200-710 Exam - Question 18


What is the output of the following code?

Show Answer
Correct Answer: A,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

5 comments
Sign in to comment
bareaOption: B
Dec 4, 2019

The correct answer is B

ZhukovPeterOption: B
Jan 4, 2020

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

[Removed]Option: B
Jun 20, 2020

The correct answer is B : 2

Andres_Espinosa1Option: B
Apr 28, 2021

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

thuanptOption: B
Oct 9, 2021

The correct answer is B : 2