<?php
class cd{
public $artist;
public $title;
protected $tracks;
private $_diskId; // regularily private varible will be star
}
//Instantiate an object of class'cd'.
$mydisk=new cd();
//Now update the artist's name.
$mydisk->artist='Justic fever';
// baby,baby,baby,hoo... baby,baby,baby,hoo.... XD
//Now try to update the protected or private values
//This will cause a fatal error.
$mydisk->tracks="Boy Friend";
?>
Fatal error: Cannot access protected property cd::$tracks
Point:it is because track was declared with protected,therefore , you cannnot access it.
a Tips for Justice fever 's fans: if declare with public,you may solve the error then. (just teasing ,no offensive)
Download for this tutorial
Download for this tutorial
No comments:
Post a Comment