getName(); 1.Nothing will be printed on-screen., 2.Foo, 3.Syntax error on line $this->name=$name, 4.Fatal error on line $this->name=$name">
MCQs > IT & Programming > PHP > What will be the output? class Person { protected $name; public function __construct($name) { $this->name = $name; } public function getName() { return $this->name; } } $person = new Person("Foo"); echo $person->getName();

PHP MCQs

What will be the output of the following code?

class Person
{
    protected $name;

    public function __construct($name) {
     $this->name = $name;
    }

    public function getName() {
     return $this->name;
    }
}

$person = new Person("Foo");

echo $person->getName();
 

Answer

Correct Answer: Foo

Explanation:

Note: This Question is unanswered, help us to find answer for this one

PHP Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

PHP Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it