Re: Classes and Global vars

From: Date: Thu, 05 Oct 2000 08:46:58 +0000
Subject: Re: Classes and Global vars
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-18709@lists.php.net to get a copy of this message
Put it all in 1 file, and then break it out. Most likely you didn't require() the file which defines "class testclass()" Also watch out for the scope of your variables. Look into the "global" declarator. Make sure when you require() that you have your include path set when you compile, or specify where you're loading from... require("..\include\config.php3"); And remember that the relative path is from your current dir if you're running the CGI version. 'Luck -Szii At 03:31 PM 10/4/00 -0500, Robert Covell wrote: >Having a heck of a time accessing vars defined in another file >(config.php3). I am using php4.0.2 and have a simple test class. > >The config file: ><? >$MESSAGE = "Test message..."; >?> > > >The class: ><? >require("config.php3"); >class testclass >{ > var $message = $MESSAGE; > > function print_message() > { > return $this->message; > } >} >?> > >When I do: ><? >$theclass=new testclass; >echo $theclass->message; > >I get: > >Parse error: parse error in /usr/local/apache/htdocs/testclass.lib on line 6 > >Fatal error: Cannot instantiate non-existent class: testclass in >/usr/local/apache/htdocs/test2.php on line 5 > > >I have no idea why. Tried to include it, and just about everything I can >think of and have no idea. Any ideas... > >-Bob > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#18709) next »