Ultra fast cheap  linux and windows hosting
See the new scripts recently added to Dynamic Drive. Click here.
Original, practical CSS codes and examples such as CSS menus for your site.
    Search code samples  
 
  Keyword
 
 
 
   
 
 
  Code Samples
 
ASP
CSS
Dhtml
Html
Javascript
PHP
 
   
     LOGIN HERE  
 
Username
Password
Forgot Password
Verify Signup
 
 
 

PHP >> General

Can I put include or require inside a class definition?

Visitor Ratings (0) :
Description
No.

You just can't put anything inside a class definition EXCEPT variable
and function definitions.

The following code is *not* legal:

<?
class Database {

/* properties */
var $db_path;
var $db_id;
var $db_fields;

/* Services */
require("open.inc");
require("close.inc");

}
?>


To clarify, the following code *does* work. This because all we have in
the class are variable and function definitions; the require() is inside
the function definition for open().
Code
Select All
 Rate this Resource