質問編集履歴
2
脱字の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
public function setOrderCount($orderCount) {
|
21
21
|
$this->orderCount = $orderCount;
|
22
22
|
}
|
23
|
-
|
23
|
+
}
|
24
24
|
$menus = new Menu();
|
25
25
|
?>
|
26
26
|
|
1
code機能利用、getName()記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,18 +3,25 @@
|
|
3
3
|
progateで学習中に以下のサンプルコードを見て
|
4
4
|
理解できない点があったので質問させていただきます。
|
5
5
|
|
6
|
+
```php
|
6
7
|
<?php
|
7
8
|
class Menu {
|
9
|
+
private $name;
|
8
|
-
|
10
|
+
private $orderCount = 0;
|
11
|
+
|
12
|
+
public function getName() {
|
13
|
+
return $this->name;
|
14
|
+
}
|
9
15
|
|
10
16
|
public function getOrderCount() {
|
11
|
-
return $this->orderCount;
|
17
|
+
return $this->orderCount;
|
18
|
+
}
|
12
19
|
|
13
|
-
public function
|
20
|
+
public function setOrderCount($orderCount) {
|
14
|
-
$this->orderCount = $orderCount;
|
21
|
+
$this->orderCount = $orderCount;
|
15
|
-
}
|
22
|
+
}
|
16
23
|
|
17
|
-
$menus = new Menu();
|
24
|
+
$menus = new Menu();
|
18
25
|
?>
|
19
26
|
|
20
27
|
<!DOCTYPE html>
|
@@ -33,7 +40,9 @@
|
|
33
40
|
</div>
|
34
41
|
</body>
|
35
42
|
</html>
|
43
|
+
```
|
36
44
|
|
45
|
+
|
37
46
|
Menuクラス内で$orderCountをprivateで指定しているにも関わらず、
|
38
47
|
クラス外から<?php $orderCount = $_POST[$menu->getName()] ?>と
|
39
48
|
セッターを介さずに値を変更できるのは何故でしょうか?
|