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
'use strict' | |
var app = require('./app'); | |
var port = process.env.PORT || 3000; | |
app.listen(port, () => { | |
console.log(`Server running in http://localhost:${port}`); | |
console.log('Defined routes:'); | |
console.log(' [GET] http://localhost:3000/'); | |
}); |
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
'use strict' | |
var express = require('express'); | |
var bodyParser = require('body-parser'); | |
var app = express(); | |
var port = process.env.PORT || 3000; | |
// Convierte una petición recibida (POST-GET...) a objeto JSON | |
app.use(bodyParser.urlencoded({extended:false})); |
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
'use strict' | |
var args = process.argv.slice(2); | |
var result = null; | |
if(args.length == 3){ | |
var num1 = parseFloat(args[0]); | |
var operation = args[1]; | |
var num2 = parseFloat(args[2]); |
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 MyDestructableClass { | |
function __construct() { | |
print "En el constructor\n"; | |
$this->name = "MyDestructableClass"; | |
} | |
function __destruct() { | |
print "Destruyendo " . $this->name . "\n"; |
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 BaseClass { | |
function __construct() { | |
print "En el constructor BaseClass\n"; | |
} | |
} | |
class SubClass extends BaseClass { | |
function __construct() { |
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 MethodTest | |
{ | |
public function __call($name, $arguments) | |
{ | |
// Nota: el valor $name es sensible a mayúsculas. | |
echo "Llamando al método de objeto '$name' " | |
. implode(', ', $arguments). "\n"; | |
} |
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; | |
/** La sobre carga sólo funciona aquí al acceder desde fuera de la clase. */ |
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 C { | |
private $prop; | |
public function __construct($val) { | |
$this->prop = $val; | |
} | |
public function __debugInfo() { |
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 A | |
{ | |
public $var1; | |
public $var2; | |
public static function __set_state($an_array) // A partir de PHP 5.1.0 | |
{ | |
$obj = new A; |