Created
November 9, 2016 09:47
-
-
Save gorkamu/430cc2f1f23246dd146a707dd92628e5 to your computer and use it in GitHub Desktop.
Ejemplo de iteración sobre un objeto
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 Gorkamu | |
{ | |
public $nombre = 'Gorkamu'; | |
public $web = 'http://www.gorkamu.com'; | |
protected $edad = '27'; | |
private $telefono = '66. ... ...'; | |
public function iterar() { | |
foreach ($this as $clave => $valor) { | |
print "$clave => $valor\n"; | |
} | |
} | |
} | |
$gorkamu = new Gorkamu(); | |
foreach($gorkamu as $clave => $valor) { | |
print "$clave => $valor\n"; | |
} | |
echo PHP_EOL; | |
$gorkamu->iterar(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment