Я создаю класс и пытаюсь его использовать.Однако установленные мной значения не сохраняются.Пожалуйста, сообщите!
Вот мое определение класса:
<?php
class MemberData
{
var $mdId;
var $mdFname;
var $mdLname;
var $mdEmail;
var $mdTwitter;
var $mdFacebook;
var $mdMyspace;
var $mdPhoneNumber;
var $mdNotes;
function MemberData($mdId, $mdFname, $mdLname, $mdEmail, $mdTwitter, $mdFacebook, $mdMyspace, $mdPhoneNumber, $mdNotes)
{
$this->mdId = $mdId;
$this->mdFname = $mdFname;
$this->mdLname = $mdLname;
$this->mdEmail = $mdEmail;
$this->mdTwitter = $mdTwitter;
$this->mdFacebook = $mdFacebook;
$this->mdMyspace = $mdMyspace;
$this->mdPhoneNumber = $mdPhoneNumber;
$this->mdNotes = $mdNotes;
}//end function
}//end MemberData class
?>
Здесь я создаю экземпляр класса и пытаюсь установить и напечатать одно из значений свойства:
<?php
include("./classes/MemberData.php");
$listMember = new MemberData();
echo "herexy";
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
switch($c){
case 0: $listMember->mdFname=$data[$c];break;
//case 0: $listMember->mdFname["blue"];break;
case 0: break;
//case 1: $listMember->mdLname($data[$c]);break;
case 2: echo "c==$c<br>";break;
case 3: echo "c==$c<br>";break;
case 4: echo "c==$c<br>";break;
case 5: echo "c==$c<br>";break;
}//end switch
}
print "listmember->mdFname == $listmember->mdFname";
}//end while
fclose($handle);
}
?>