πŸ“Š PHP
Q. What will be the output?
Code:
class A { public function __toString() { return 'Hello'; } }
$obj = new A();
echo $obj;
  • (A) Hello
  • (B) Object
  • (C) Error
  • (D) NULL
πŸ’¬ Discuss
βœ… Correct Answer: (A) Hello

Explanation: __toString() is invoked when object is echoed.

Explanation by: Roshan
__toString() is invoked when object is echoed.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
1
Total Visits
πŸ“½οΈ
8 d ago
Published
πŸŽ–οΈ
Roshan
Publisher
πŸ“ˆ
84%
Success Rate