|
Steve A. - 30 Aug 2008
May 25, 2006
Oops. Obviously in the previous post I forgot the
<?php
Also, I've been wondering why I didn't have to declare the $Name variable in the class defintion for this to work. Does $poppy->Name="Poppy"; create the $Name variable?
Steve A. - 30 Aug 2008
Scot, this works for me in PHP 5:
class dog {
public function bark() {
print "{$this->Name} says Woof!";
}
}
class poodle extends dog {
}
$poppy = new poodle;
$poppy->Name="Poppy";
$poppy->bark();
?>
Outputs "Poppy says woof!"
ScotDiddle@overnite.com - 30 Aug 2008
I could not get this example to work. Please clarify. Thank-you. Scot L. Diddle, Richmond VA
micah.frost@gmail.com - 30 Aug 2008
" Whenever you are inside a function of an object, PHP automatically sets the $this variable contains that object - you do not need to do anything to have access to it."
Whenever you are calling an object's function, the $this variable is set to the object whose function is being called.
chris.hearn01@ntlworld.com - 30 Aug 2008
Hi there,
Having been involved in other things for a while, just came back to reading your book a bit more.
Two quick points.
a)
" Whenever you are inside a function of an object, PHP automatically sets the $this variable contains that object - you do not need to do anything to have access to it."
Sorry, this is not English - or at least, not to me - what does it mean?
(i think it's saying when inside a function of an object, $This-> refers to the object?)
b) it would be helpful to have next page/last page links at the TOP of each page, as i find when scanning through the pages I have to move to the bottom each time. (And maybe a next/last chapter link as well??)
Still think it's a great on-line book though!
Cheers
Chris
Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.
If you are reporting an error in the content, please tell me directly.
|