Last active
April 5, 2018 07:46
-
-
Save terremoth/84df3b99366618e6b79f00fa4818cb37 to your computer and use it in GitHub Desktop.
Answering question in "Desenvolvimento Web" facebook group
This file contains 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 Car | |
{ | |
// As variáveis da classe são propriedades do objeto "Car" | |
private $name; // isto é uma propriedade | |
protected $color; // isto também é | |
public $brand; // e isto também é | |
public function __construct($name, $color, $brand) | |
{ | |
$this->name = $name; | |
$this->color = $color; | |
$this->brand = $brand; | |
// ... | |
// e esta função é um método construtor | |
} | |
// esta função também é um método | |
public function getName() | |
{ | |
return $this->name; | |
} | |
public function getColor() | |
{ | |
return $this->color; | |
} | |
public function getBrand() | |
{ | |
return $this->brand; | |
} | |
// todas as funções de um objeto são métodos dele | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment