Re: Class rules

From: Date: Tue, 17 Feb 2004 22:17:14 +0000
Subject: Re: Class rules
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-178029@lists.php.net to get a copy of this message
From: "Alex Hogan" <Alex.Hogan@AlliedElec.com> > What are the rules of thumb for classes and included files? > > Can I not include a file in a class function? If I put the include() > outside the class structure everything works fine, but when I put it inside > the class it freaks. > > Am I doing something wrong? > > Class myclass{ > Include('myfile'); -- doesn't work > Funciton myfunc($var1, $var2){ > Include('myfile'); -- doesn't work > } > } It depends what's in the include file. You can do that, but the end result has to be a valid class. Using an include is basically like cutting and pasting the file at the point you have include(). So, if you're doing it this way, "myfile" must be variable declarations or methods, since you're already inside the class. ---John Holmes...

« previous php.general (#178029) next »