private $istr1 = "private string.\n";
protected $istr2 = "protected string.\n";
public $istr3 = "public string.\n";
private static $sstr1 = "private static string.\n";
protected static $sstr2 = "protected static string.\n";
public static $sstr3 = "public static string.\n";
//クラス内からは全部のインスタンス変数にアクセスできるはず。
public function checkInstance()
echo $this->name." checkInstance\n";
public function checkStatic()
echo $this->name." checkStatic\n";
class Extension extends Visiblity
public function checkParent()
echo $this->name." checkParent\n";
//echo $this->istr1; //Notice: Undefined property: Extension::$istr1
public function checkParentStatic()
echo $this->name." checkParentStatic\n";
//echo parent::$sstr1; //Fatal error: Cannot access private property Visiblity::$sstr1
//echo Visiblity::$sstr1; //Fatal error: Cannot access private property Visiblity::$sstr1
//echo Visiblity::$sstr2; //Fatal error: Cannot access protected property Visiblity::$sstr2
//echo $var->istr1; //Fatal error: Cannot access private property PropertyVisiblity::$istr1
//echo $var->istr2; //Fatal error: Cannot access protected property PropertyVisiblity::$istr2
echo $var->istr3; //public string.
$child = new Extension();
$child->checkParentStatic();