[thelist] PHP n00b

Kevin Stevens kjs at ratking.co.uk
Fri Jan 4 10:38:12 CST 2008

I'm looking for a job in web design and a friend recommended I learn PHP 
because it I'm more likely to find something with that skill than the 
ASP I already know. But, quite frankly, I'm struggling a bit. I bought 
the latest O'Reilly book http://www.oreilly.com/catalog/9780596514013/ 
but I'm not finding that it explains things very well. One of the 
examples of code is below...


class cat
          var $age;
          function cat($now_age) { $this->age = $now_age; }
          function birthday() { $this->age++; }
$fluffy = new cat(1);
echo "Age is $fluffy->age <br>";
echo "Birthday<br>";


echo "Age is $fluffy->age <br>";

Could somebody tell me if my understanding of this is correct please. 
The piece of code '$this->age = $now_age' is what is baffling me

1. I am declaring $age as a variable
2. Presumably I cannot use a variable as a parameter of a function, so 
'$this->age = $now_age' effectively puts the value of the variable into 
the parameter. Is this right?

If I am correct it seems a pretty ar$e-about-face way of doing things, 
the purpose of which will no doubt be revealed to me at some later date

Thanks, and a (belated) Happy New Year to you all :)

Kevin Stevens

More information about the thelist mailing list