Skip to content

Instantly share code, notes, and snippets.

@myanmarlinks
Created August 9, 2017 06:40
Show Gist options
  • Save myanmarlinks/353417280bfa8da76e1aab174a44efe2 to your computer and use it in GitHub Desktop.
Save myanmarlinks/353417280bfa8da76e1aab174a44efe2 to your computer and use it in GitHub Desktop.
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