Page 1 of 1
nested class declarations
Posted: Sat Jun 08, 2002 4:56 am
by rats
Getting this error. Has anyone an idea what the error message refers too?
The error points to a class such as
<?php
class user
{ //the third line?
Fatal error: Class declarations may not be nested in includes/DB.php on line 3
thanks
The rest of the code was to much to post.
Posted: Sat Jun 08, 2002 5:54 am
by volka
check the other classes that are interpreted (included) earlier.
May be you've forgotten the closing bracket.
A class within a class
Posted: Sun Jun 09, 2002 5:21 pm
by BDKR
Does the code look somethng like....
Code: Select all
<?php
class joe_schmo
{
# Then somewhere within
class jane_schmo
{
# Do stuff
}
# End nested class
}
# End original class
?>
In short, this kind of thing is not allowed.
Later on,
Big Din K.R.
nesting classes
Posted: Sun Jun 09, 2002 5:46 pm
by rats
yeah found the problem..
Cant have a required_once("database.php"); inside another class.
but yes you can call a constructor of another class from within this class.
Thanks for your help.
Posted: Sun Jun 09, 2002 9:45 pm
by fatal
this might interest you about nested classes:
http://www.php.net/source.php?url=/zend2_example.php
Its example 3