In my course, I'm learning getters that gets "data" and setters , which inserts / modifies.
I made my code like this for pen class:
<?php
class Caneta {
public $modelo;
private $ponta;
public function getModelo(){
return $this->modelo;
}
public function setModelo($m){
$this->modelo = $m;
}
public function getPonta(){
return $this->ponta;
}
public function setPonta($p) {
$this->ponta = $p;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Aula 02 POO</title>
</head>
<body>
<pre>
<?php
require_once 'Caneta.php';
$c1 = new Caneta;
$c1->setModelo("BIC");
$c1->setPonta(0.5);
print("Eu tenho uma caneta {$c1->getModelo()} com a ponta {$c1->getPonta()}");
?>
</pre>
</body>
</html>
In the case of those words there, set and get , could I swap for any other? For example (only doubt), could you do so?
<?php
class Caneta {
public $modelo;
private $ponta;
public function puxarModelo(){
return $this->modelo;
}
public function inserirModelo($m){
$this->modelo = $m;
}
public function puxarPonta(){
return $this->ponta;
}
public function inserirPonta($p) {
$this->ponta = $p;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Aula 02 POO</title>
</head>
<body>
<pre>
<?php
require_once 'Caneta.php';
$c1 = new Caneta;
$c1->inserirModelo("BIC");
$c1->inserirPonta(0.5);
print("Eu tenho uma caneta {$c1->puxarModelo()} com a ponta {$c1->puxarPonta()}");
?>
</pre>
</body>
</html>
I'm learning with get and set , but I was wondering if this is standard / mandatory, or if I can change (if I want to) without problems?