[PHP] error cannot instantiate non-existent class

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default [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

  2. Similar Questions and Discussions

    1. 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. ...
    2. #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...
    3. #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...
    4. #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: ...
    5. [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...
  3. #2

    Default Re: [PHP] error cannot instantiate non-existent class

    From: "Golawala, Moiz M (IndSys, GE Interlogix)" <Moiz.Golawala@ge.com>
    > I am newbie with php and I am trying to instantiate a
    > class.
    Welcome to PHP.
    > this->$config = $config;
    $this->config = $config;
    > 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

    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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139