Re: Using a Resource as a Class Property



Sanders Kaufman wrote:

So extended (child?) classes MUST NOT (for OOP reasons) automatically
call a constructor. Rather, it should be called manually, if and when
it's desired.

s/MUST NOT/DO NOT/

Of course, if you don't define a __construct() method in the child
class, the parent class' constructor will get called automatically.

Basically, in PHP __construct() behaves the same way other methods
do: if you define the method in a child class, the parent class'
method will be ignored, unless you explicitly call it from within
the child class' method (using "parent::method()").

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 32 days, 12:11.]

Parsing an HTML Table with PEAR's XML_HTTPSax3
http://tobyinkster.co.uk/blog/2007/07/20/html-table-parsing/
.



Relevant Pages

  • Re: PHP 4: does method_exist return true if parent class method even if child class forgot to call p
    ... > in the constructor of the child class. ... > method_exists was testing true, though the method was not truly ... You shouldn't have to call the parent class to get access to its ...
    (comp.lang.php)
  • Re: Strange Static contstructor behavior
    ... I want the derived classes ... Then you only want one instance of the parent class. ... The static constructor still fires twice. ... I think instead you would want to create a non-generic base class that is composited into the generic class rather than being inherited. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using a Resource as a Class Property
    ... if you don't define a __constructmethod in the child ... the parent class' constructor will get called automatically. ... In OOP the constructor of the grandest child:) will be called when a class is instantiated as an object. ...
    (comp.lang.php)
  • Re: accessing protected data members of instance of parent class
    ... > | them without accessor methods. ... > | properly copies those data members. ... > You haven't said wheter the Parent class had an accessible ... the parent class does not have a copy constructor -- or even an ...
    (comp.lang.cpp)
  • Re: Strange Static contstructor behavior
    ... these static variables that are populated by the parent. ... Then you only want one instance of the parent class. ... The static constructor still fires twice. ... generic class is created on your behalf. ...
    (microsoft.public.dotnet.languages.csharp)