Created
August 7, 2019 21:35
-
-
Save parzibyte/54ea395e01b0f6f091454848db871202 to your computer and use it in GitHub Desktop.
Método toString en clase de PHP - https://parzibyte.me/blog/2018/10/03/php-intval-y-strval-para-convertir-variables/
This file contains 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 Mascota{ | |
var $nombre; | |
public function __construct($nombre){ | |
$this->nombre = $nombre; | |
} | |
public function ladrar(){ | |
echo "¡Guau!"; | |
} | |
public function __toString(){ | |
return "Soy de la clase mascota. Mi nombre es " . $this->nombre; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment