Skip to content

Instantly share code, notes, and snippets.

@gorkamu
Created December 25, 2016 11:44
Show Gist options
  • Select an option

  • Save gorkamu/d55f7dabbb58bcf0b44a6b3a1f60e9ed to your computer and use it in GitHub Desktop.

Select an option

Save gorkamu/d55f7dabbb58bcf0b44a6b3a1f60e9ed to your computer and use it in GitHub Desktop.
Ejemplo del método mágico __toString()
<?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