-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexemplo_class.php
More file actions
executable file
·64 lines (51 loc) · 909 Bytes
/
exemplo_class.php
File metadata and controls
executable file
·64 lines (51 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
class Animal
{
private $nome = 'Macaco';
//antes era assim
// public function Animal()
// {
// echo $this->nome;
// }
public function __construct()
{
}
/**
* @return string
*/
public function getNome()
{
return ($this->nome);
}
/**
* @param string $nome
*/
public function setNome($nome)
{
$this->nome = $nome;
}
}
$b = 'd';
$fun = function ($n) use ($b) {
return strtoupper($n) . '-' . $b;
};
$arr = [1, 2, 3, 4];
for ($i = 0; $i < count($arr); $i++) {
//echo $arr[$i] . '<br>';
}
foreach ($arr as $item) {
// echo $item . '<br>';
}
$i = 0;
while ($i < count($arr)) {
$i++;
echo $arr[$i] . '<br>';
}
array_filter($arr,
function ($item) {
// echo $item . '<br>';
});
$a = new Animal();
echo $a->getNome();
$a->setNome('Gato');
echo $fun($a->getNome());