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
・ 変数は「名札」である。(「参照」みたいなもの) | |
num = 10 | |
print(num) | |
num = 12 | |
print(num) | |
別のオブジェクトを代入するということは、変数を別のオブジェクトの名札に変更したということになります。 | |
上記の場合は最初の「print」メソッドでは「10」が出力されますが、 |
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 CodeTest{ | |
public $name; | |
public function __construct($name = '名無し'){ | |
$this->name = $name; | |
} | |
public function morning(){ | |
echo $this->name."さん、おはようございます。"; | |
} |