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 | |
| $nombre = 'Gorkamu'; | |
| function saluda($nombre) { | |
| $nombre = 'Gorkamu eres un gandul!'; | |
| echo 'Hola '.$nombre.PHP_EOL; | |
| } | |
| echo $nombre; // Imprime 'Gorkamu' |
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 | |
| $nombre = 'Gorkamu'; | |
| function saluda(&$nombre) { | |
| $nombre = 'Fino'; | |
| return $nombre; | |
| } | |
| echo $nombre; // Imprime 'Gorkamu' |
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 | |
| function saluda($nombre = 'Gorka') { | |
| echo 'Hola '.$nombre.PHP_EOL; | |
| } | |
| saluda(); // Imprime 'Hola Gorka' | |
| saluda('Fino'); // Imprime 'Hola Fino' |
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 | |
| function sum(...$nombres) { | |
| $saludo = 'Hola '; | |
| foreach ($nombres as $nombre) { | |
| $saludo .= $nombre; | |
| } | |
| return $saludo; | |
| } |
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 Numero | |
| { | |
| private $valor; | |
| public function __construct($valor) { | |
| $this->valor = $valor; | |
| } | |
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 | |
| function bool2str($bool) | |
| { | |
| if ($bool === false) { | |
| return 'FALSO'; | |
| } else { | |
| return 'VERDADERO'; | |
| } | |
| } |
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 SubObject | |
| { | |
| static $instances = 0; | |
| public $instance; | |
| public function __construct() { | |
| $this->instance = ++self::$instances; | |
| } |
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'; | |
| } | |
| $gorkamu = new Gorkamu(); | |
| $serialize = serialize($gorkamu); |
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. ... ...'; |
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 MiIterador implements Iterator | |
| { | |
| private $var = array(); | |
| public function __construct($array) | |
| { | |
| if (is_array($array)) { | |
| $this->var = $array; |