For those of you who helped me with Class Human->leslie I appreciate it greatly. Working on that, I found out I still don't know how to declare an array, and print it out in OO environment, so I made this little script and sure enough it does not work. Would you give me some pointers on what I am doing wrong please.
This program is suppose to declare an array in a class and then pass it some numbers and print out the key and value. The initialization should take place in __construct().
<?php
class Human
{
private $number;
function __construct($key, $value) {
$this->number [$key] = $value;
}
function __get($value)
{
foreach($number as $key => $value)
echo $key.'=>'.$value.'<br />';
}
}
$number = new Human();
$number->first = 1;
$number->second = 2;
$number->third = 3;
$number->fourth = 4;
?>
p.s. I am trying to think of different examples to learn how a __construct works and what it does, how OO works, etc...
Although I read the php manual and I know what it does, I am having trouble implementing it. So, I am making these examples.
Thank you