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 CallableClass | |
{ | |
public function __invoke($x) | |
{ | |
var_dump($x); | |
} | |
} |
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; | |
} |
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 Connection | |
{ | |
protected $link; | |
private $dsn, $username, $password; | |
public function __construct($dsn, $username, $password) | |
{ | |
$this->dsn = $dsn; |
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 Pantoja | |
{ | |
protected static $nombre = 'Isabel Pantoja'; | |
public static function comoMeLlamo() | |
{ | |
return static::$nombre; | |
} |
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 Taza | |
{ | |
public static function getName() | |
{ | |
echo 'Soy una taza'; | |
} | |
public static function queSoy() |
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 ReyFelipe extends ReyJuanCarlos | |
{ | |
} |
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 | |
new class { | |
function __construct() | |
{ | |
(static function() { | |
var_dump($this); | |
})(); | |
} | |
}; |
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 | |
$mensaje = 'hola'; | |
// Sin "use" | |
$ejemplo = function () { | |
var_dump($mensaje); | |
}; | |
$ejemplo(); // Notice: Undefined variable: message in /example.php on line 7 |
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 | |
$saludo = function($nombre) | |
{ | |
printf("Hola %s\r\n", $nombre); | |
}; | |
$saludo('Gorkamu'); // Hola Gorkamu | |
$saludo('yonkis del metal'); // Hola yonkis del metal |
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 PropertyTest | |
{ | |
/** Localización de los datos sobrecargados. */ | |
private $data = array(); | |
/** La sobrecarga no se usa en propiedades declaradas. */ | |
public $declared = 1; |