Hello,

I wrote a PHP class to display an HTML calendar, and then wrote a subclass
of it for a specific project I'm working on.  Here is the entirety of the
subclass:

// create our new sub-class of the calendar
class rantCal extends calendar {
  function get_link($day) {
    $link = "";
    if (valid_date($this->my_year, $this->my_month, $day)) {
      if (rant_exists($this->my_year, $this->my_month, $day)) {
        $link = "index.php?date=$this->my_year-$this->my_month-$day";
      }
    }
    return $link;
  }
}

Basically, it's used to determine if a given date should be linked or not.
When I wrote it, I didn't expect it to work, since these two function:

valid_date()
rant_exists()

are defined completely outside of the class.  In fact, they're defined in
a functions file that I include (with include()) above where I define my
rantCal class.  Shouldn't their names not be recognized within this class?
I was assuming that a class was entirely self-contained, so it can't know
about functions defined outside its scope.  However, it works just fine
(that is, the functions get called), which is helpful, but it doesn't seem
like the way things should work.

Am I completely wrong?  I seem to recall that this sort of thing should
work in a more strict OO language, like C++.

I'm using PHP 4.0.6, if that's important.

-- 
[ joel boonstra | [EMAIL PROTECTED] ]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to