Pick the correct purpose of implementing __toString() on a class.
echo $money; is used directly on an object of a custom Money class, and it prints a formatted value instead of an error.
Ready to try it?
Create a free account and try "The __toString() Magic Method" free for 7 days, no card required. Earn 70 XP and track your internship progress.
Already have an account? Sign in