Skip to content

Instantly share code, notes, and snippets.

@gorkamu
Created November 8, 2016 06:10
Show Gist options
  • Save gorkamu/2b6857d5051b81476ba3ad79abe08d58 to your computer and use it in GitHub Desktop.
Save gorkamu/2b6857d5051b81476ba3ad79abe08d58 to your computer and use it in GitHub Desktop.
Ejemplo de constructor
<?php
class Gorkamu
{
private $salario;
private $medidas;
public function __construc($salario, $medidas) {
$this->salario = $salario;
$this->medidas = $medidas;
}
public function cuantoMido() {
return $this->medidas;
}
public function cuantoCobro() {
return $this->salario;
}
}
$gorkamu = new Gorkamu('3000 €', '33cm'); // Tipico forocochero
echo $gorkamu->cuantoMido(); // Imprime '33cm'
echo $gorkamu->cuantoCobro(); // Imprime '3000 €'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment