cannot recognize class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
The_Percival
Forum Newbie
Posts: 2
Joined: Sat Jun 04, 2005 5:57 pm

cannot recognize class

Post by The_Percival »

I get the error : "Fatal error: Cannot instantiate non-existent class".

I call :
$Languages = $FootballEye->GetLanguages();

$FootballEye is known is no problem!

$FootballEye.php:
include("Language.php");

class FootballEye
{
...

function GetLanguages()
{
this->$Languages = new $Languages();

}

Now $Languages is not known while I include Language.php in the top of file $FootballEye.php.

Has anybody an idea? Can I use new in a class?

Why does this not work?

Thanks in advance!

Coen Dunnink
The Netherlands
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

put the class before you include the language file. :/
The_Percival
Forum Newbie
Posts: 2
Joined: Sat Jun 04, 2005 5:57 pm

Why should I include the language file at all then?

Post by The_Percival »

Why should I include the language file at all then?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Code: Select all

$fb = new FootballEye();
$Languages = $fb->GetLanguages();
In your method GetLanguages(), are you not returning anything ?
$this->Languages not this->$Languages - slightly different from C++ Class.

Code: Select all

function GetLanguages()
{
 $this->Languages = new $Languages();
 // return $this->Languages->something();
}
Post Reply