For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > July 2004 > Notice: Use of undefined constant string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Notice: Use of undefined constant string
Vince

2004-07-23, 8:56 am


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

2004-07-23, 8:56 am

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


eclipsboi

2004-07-23, 8:55 pm

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 <mesca@fr.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
>
>
>
>


steve

2004-07-24, 3:56 pm

"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[color=darkred]
> 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 <mesca@fr.fm> wrote:
>
> an
> php.ini...

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.

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

2004-07-24, 8:55 pm

On Sat, 24 Jul 2004 19:23:05 -0000, steve
<UseLinkToEmail@dbForumz.com> wrote:

>"eclipsboi" wrote:
> <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. :)
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com