Professional Web Applications Themes

Notice: Use of undefined constant string - PHP Development

Hi there ! I am trying to program in object mode using easyphp1-7. When I create an object, php engine returns : Notice: Use of undefined constant string .. I've been searching a lot the bug in my code...it says I use an undefined constant which it is wrong... Here the code where the 'notice' appears: $my_var = ""; $my_var = new my_Object(); and I also tried without initialization: $my_var = new my_Object(); I'm thinking about disabling 'notice error' in php.ini... any idea ?? thanks lot:) Vince...

  1. #1

    Default Notice: Use of undefined constant string


    Hi there !

    I am trying to program in object mode using easyphp1-7.
    When I create an object, php engine returns :

    Notice: Use of undefined constant string ..

    I've been searching a lot the bug in my code...it says I use an
    undefined constant which it is wrong...

    Here the code where the 'notice' appears:
    $my_var = "";
    $my_var = new my_Object();

    and I also tried without initialization:
    $my_var = new my_Object();

    I'm thinking about disabling 'notice error' in php.ini...

    any idea ??

    thanks lot:)

    Vince





    Vince Guest

  2. #2

    Default Re: Notice: Use of undefined constant string

    Hello,
    You need to change your php.ini file

    find the word "error_reporting" in your php.ini file and make the

    change like below..

    error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT


    regards
    R.Sureshkannan


    On Fri, 23 Jul 2004 11:43:58 +0200, Vince wrote:
    >
    > Hi there !
    >
    > I am trying to program in object mode using easyphp1-7.
    > When I create an object, php engine returns :
    >
    > Notice: Use of undefined constant string ..
    >
    > I've been searching a lot the bug in my code...it says I use an
    > undefined constant which it is wrong...
    >
    > Here the code where the 'notice' appears:
    > $my_var = "";
    > $my_var = new my_Object();
    >
    > and I also tried without initialization:
    > $my_var = new my_Object();
    >
    > I'm thinking about disabling 'notice error' in php.ini...
    >
    > any idea ??
    >
    > thanks lot:)
    >
    > Vince
    Kannan S Guest

  3. #3

    Default Re: Notice: Use of undefined constant string

    You don't need to change your config or anything. Look through your
    code for something like this:

    Wrong:
    $some_array[some_string]

    Right:
    $some_array['some_string']

    Notice there are no quotes around some_string in the Wrong example;
    that tells PHP to look for a constant by that name, and the way PHP
    works is that if it doesn't find it, it will assume it's an
    associative index, and if you have Notices set to report, it will spit
    out the error.

    So, the long story short, it's good practice to always, always, always
    quote your string indexes... as somewhere in the PHP manual says, in
    the future they may stop making assumptions of this kind. Better to
    write the code correctly by taking the time to write two single
    quotes, then to have to go back later and fix your code.

    On Fri, 23 Jul 2004 11:43:58 +0200, Vince <mescafr.fm> wrote:
    >
    >Hi there !
    >
    >I am trying to program in object mode using easyphp1-7.
    >When I create an object, php engine returns :
    >
    >Notice: Use of undefined constant string ..
    >
    >I've been searching a lot the bug in my code...it says I use an
    >undefined constant which it is wrong...
    >
    >Here the code where the 'notice' appears:
    >$my_var = "";
    >$my_var = new my_Object();
    >
    >and I also tried without initialization:
    >$my_var = new my_Object();
    >
    >I'm thinking about disabling 'notice error' in php.ini...
    >
    >any idea ??
    >
    >thanks lot:)
    >
    >Vince
    >
    >
    >
    >
    eclipsboi Guest

  4. #4

    Default Re: Re: Notice: Use of undefined constant string

    "eclipsboi" wrote:
    > You donít need to change your config or anything. Look through
    > your
    > code for something like this:
    >
    > Wrong:
    > $some_array[some_string]
    >
    > Right:
    > $some_array[ísome_stringí]
    >
    > Notice there are no quotes around some_string in the Wrong example;
    > that tells PHP to look for a constant by that name, and the way PHP
    > works is that if it doesnít find it, it will assume itís
    > an
    > associative index, and if you have Notices set to report, it will
    spit
    > out the error.
    >
    > So, the long story short, itís good practice to always, always,
    > always
    > quote your string indexes... as somewhere in the PHP manual says,
    in
    > the future they may stop making assumptions of this kind. Better to
    > write the code correctly by taking the time to write two single
    > quotes, then to have to go back later and fix your code.
    >
    > On Fri, 23 Jul 2004 11:43:58 +0200, Vince <mescafr.fm> wrote:
    >
    > >
    > >Hi there !
    > >
    > >I am trying to program in object mode using easyphp1-7.
    > >When I create an object, php engine returns :
    > >
    > >Notice: Use of undefined constant string ..
    > >
    > >Iíve been searching a lot the bug in my code...it says I use
    > an
    > >undefined constant which it is wrong...
    > >
    > >Here the code where the ínoticeí appears:
    > >$my_var = "";
    > >$my_var = new my_Object();
    > >
    > >and I also tried without initialization:
    > >$my_var = new my_Object();
    > >
    > >Iím thinking about disabling ínotice errorí in
    > php.ini...
    > >
    > >any idea ??
    > >
    > >thanks lot:)
    > >
    > >Vince
    > >
    > >
    > >
    > ></font>
    Just a general comment:
    To 2nd eclipsboi, I donít recommend disabling any error reporting.
    Thatís the lazy way of doing things, and it is gonna get you in the
    long run. You are going to lose the ability to find some pesky bugs
    that would otherwise not show up.

    --
    [url]http://www.dbForumz.com/[/url] This article was posted by author's request
    Articles individually checked for conformance to usenet standards
    Topic URL: [url]http://www.dbForumz.com/PHP-Notice-undefined-constant-string-ftopict132573.html[/url]
    Visit Topic URL to contact author (reg. req'd). Report abuse: [url]http://www.dbForumz.com/eform.php?p=443886[/url]
    steve Guest

  5. #5

    Default Re: Notice: Use of undefined constant string

    On Sat, 24 Jul 2004 19:23:05 -0000, steve
    <UseLinkToEmaildbForumz.com> wrote:
    >"eclipsboi" wrote:
    > > You donít need to change your config or anything.
    > <snip>
    >
    >Just a general comment:
    >To 2nd eclipsboi, I donít recommend disabling any error reporting.
    >Thatís the lazy way of doing things, and it is gonna get you in the
    >long run. You are going to lose the ability to find some pesky bugs
    >that would otherwise not show up.
    Reread my very first sentence; I said you do not need to change config
    or anything; anything meaning disabling error reporting also. :)
    eclipsboi Guest

Similar Threads

  1. Undefined variable notice error
    By Doug in forum PHP Development
    Replies: 1
    Last Post: May 11th, 03:12 PM
  2. undefined constant
    By griemer in forum PHP Development
    Replies: 1
    Last Post: January 10th, 06:49 PM
  3. Notice: Undefined variable
    By PONTEPRIMO in forum PHP Development
    Replies: 1
    Last Post: November 7th, 09:56 PM
  4. adUseServer Constant Undefined
    By Wayne Wengert in forum ASP
    Replies: 6
    Last Post: September 15th, 06:51 AM
  5. #20558 [Bgs]: Notice: Undefined variable:
    By philip@php.net in forum PHP Development
    Replies: 0
    Last Post: August 4th, 11:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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