Skip to content

Instantly share code, notes, and snippets.

@terremoth
Last active April 5, 2018 07:46
Show Gist options
  • Save terremoth/84df3b99366618e6b79f00fa4818cb37 to your computer and use it in GitHub Desktop.
Save terremoth/84df3b99366618e6b79f00fa4818cb37 to your computer and use it in GitHub Desktop.
Answering question in "Desenvolvimento Web" facebook group
<?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