Created
December 25, 2016 11:44
-
-
Save gorkamu/d55f7dabbb58bcf0b44a6b3a1f60e9ed to your computer and use it in GitHub Desktop.
Ejemplo del método mágico __toString()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class TestClass | |
| { | |
| public $foo; | |
| public function __construct($foo) | |
| { | |
| $this->foo = $foo; | |
| } | |
| public function __toString() | |
| { | |
| return $this->foo; | |
| } | |
| } | |
| $class = new TestClass('Hola Mundo'); | |
| echo $class; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment