Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP Magic Method __toString()
<?php
class Dog {
public $test = "Hello from Dog Class";
public function __toString() {
return $this->test;
}
}
$dog = new Dog();
echo $dog;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment