Ask a Question related to PHP Development, Design and Development.
-
Moiz M Golawala #1
[PHP] error cannot instantiate non-existent class
I am newbie with php and I am trying to instantiate a class. I am using the command line to test my stuff out before I try it with a browser. The following is my class code: (name of file is AddConfigs.inc)
<?php
class AddConfigs{
var $config;
function AddConfigs($config){
this->$config = $config;
echo " in constructor $config ";
echo " in constructor statement 2 ".$config;
}
}
?>
The following is the code of the file I am trying to instantiate the class with: (name of file is test.php)
<?php
require('C:/Program Files/Apache Group/Apache2/htdocs/Alarms/AddConfigs.inc');
$a = new AddConfigs('testing');
?>
I type in "php test1" and I get the following errors:
Parse error: parse error, unexpected T_OBJECT_OPERATOR in C:\Program Files\Apache Group\Apache2\htdocs\Alarms\AddConfigs.inc on line 7
Fatal error: Cannot instantiate non-existent class: addconfigs in C:\Program Files\Apache Group\Apache2\htdocs\Alarms\test1.php on line 4
Please can someone help me...?
Many Thanks
Moiz
Moiz M Golawala Guest
-
Cannot instantiate .NET Class Library to expose webservice client library
Now that I have got the mickey mouse .NET interop problem sorted (exposing ..NET library to ASP/VB6), I want to demo the real problem I am having. ... -
#25580 [WFx]: set_error_handler to a class/method resets class properties when error occurs
ID: 25580 Updated by: sniper@php.net Reported By: paul dot liversidge at recycledpixels dot com Status: Wont... -
#25580 [Opn->WFx]: set_error_handler to a class/method resets class properties when error occurs
ID: 25580 Updated by: sniper@php.net Reported By: paul dot liversidge at recycledpixels dot com -Status: Open... -
#25580 [NEW]: set_error_handler to a class/method resets class properties when error occurs
From: paul dot liversidge at recycledpixels dot com Operating system: Windows XP PHP version: 4.3.2 PHP Bug Type: ... -
[PHP] vars between instantiate class...
hi, This is because the life time of an object is only as long as the page. Two solutions: store the login attempt count in the cookies. If you... -
Cpt John W. Holmes #2
Re: [PHP] error cannot instantiate non-existent class
From: "Golawala, Moiz M (IndSys, GE Interlogix)" <Moiz.Golawala@ge.com>
Welcome to PHP.> I am newbie with php and I am trying to instantiate a
> class.
$this->config = $config;> this->$config = $config;
C:\Program Files\Apache Group\Apache2\htdocs\Alarms\test1.php on line 4> Parse error: parse error, unexpected T_OBJECT_OPERATOR
> in C:\Program Files\Apache Group\Apache2\htdocs
> \Alarms\AddConfigs.inc on line 7
>
> Fatal error: Cannot instantiate non-existent class: addconfigs in
That first error is being caused by your syntax error above. Since there is
parse error in the class file, the second file cannot create an instance of
the class, hence the second error. Fix that line above and both will go
away.
---John Holmes...
Cpt John W. Holmes Guest



Reply With Quote

