Skip to content

Instantly share code, notes, and snippets.

View kenta-polyglot's full-sized avatar

Kenta Katsumata kenta-polyglot

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