National_Instruments
200-500 · Question #22
200-500 Question #22: Real Exam Question with Answer & Explanation
The correct answer is A. Change var to public or private B. Change function Car to function_construct. See the full explanation below for the reasoning.
Question
Which of the listed changes would you make to the following PHP 4 code in order to make it most compliant with PHP 5? (Choose 2) <?php class Car { var $model; function Car($model) { $this->model = $model; } function toString() { return "I drive a $this->model."; }} $c = new Car('Dodge'); echo $c->toString(); ?>
Options
- AChange var to public or private
- BChange function Car to function_construct
- CChange "I drive a $this->model." to "I drive a {$this->model}."
- DChange function toString()to static function toString()
Community Discussion
No community discussion yet for this question.