FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » way to turn off strict option? Use of undefined constant
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
way to turn off strict option? Use of undefined constant [message #177142] Thu, 23 February 2012 16:01 Go to next message
Paul is currently offline  Paul
Messages: 3
Registered: February 2012
Karma: 0
Junior Member
I installed a new version of PHP and now am getting errors on my pages
that say:

Notice: Use of undefined constant....

Is there any way in the page that I can add some code so I do not get
these errors? I just want to get this working and will go back and
fix this later.

But maybe there is a way like in VB a way to turn off Option
Explicit ?
thanks
Re: way to turn off strict option? Use of undefined constant [message #177143 is a reply to message #177142] Thu, 23 February 2012 17:21 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(Paul)

> I installed a new version of PHP and now am getting errors on my pages
> that say:
>
> Notice: Use of undefined constant....
>
> Is there any way in the page that I can add some code so I do not get
> these errors?

You can turn off notices (see error_reporting()), but the errors still
exist and you should fix them as soon as possible. The above for example
is the result of accessing an array element with an unquoted string key:

$foo = $array[bar];

Correct would be:

$foo = $array['bar'];

Micha

--
http://mfesser.de/blickwinkel
Re: way to turn off strict option? Use of undefined constant [message #177146 is a reply to message #177142] Thu, 23 February 2012 18:00 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 23/02/2012 17:01, Paul escribió/wrote:
> I installed a new version of PHP and now am getting errors on my pages
> that say:
>
> Notice: Use of undefined constant....
>
> Is there any way in the page that I can add some code so I do not get
> these errors? I just want to get this working and will go back and
> fix this later.
>
> But maybe there is a way like in VB a way to turn off Option
> Explicit ?

Not exactly, but quite similar. You have a few choices:

- Hide error messages:
http://es2.php.net/manual/en/errorfunc.configuration.php#ini.display-errors

- Log error messages:
http://es2.php.net/manual/en/errorfunc.configuration.php#ini.error-log

- Ignore certain error types:
http://es2.php.net/manual/en/errorfunc.configuration.php#ini.error-reportin g

These options can be combined to your liking. You can set them in
several places:

1. Edit your `php.ini` file:

error_reporting = E_ALL & ~E_NOTICE
display_errors = On

2. Put this on top of your script:

<?php

error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', TRUE);

3. If PHP runs as Apache module, you can also use an `.htaccess` file:

# Print E_ALL & ~E_NOTICE from a PHP script to get the appropriate number:
php_value error_reporting 30711
php_flag display_errors on


In your dev box I'd recommend E_ALL | E_STRICT.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: way to turn off strict option? Use of undefined constant [message #177149 is a reply to message #177142] Thu, 23 February 2012 21:55 Go to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Thu, 23 Feb 2012 08:01:48 -0800 (PST), Paul wrote:
> I installed a new version of PHP and now am getting errors on my pages
> that say:
>
> Notice: Use of undefined constant....
>
> Is there any way in the page that I can add some code so I do not get
> these errors? I just want to get this working and will go back and
> fix this later.
>
> But maybe there is a way like in VB a way to turn off Option
> Explicit ?

Or you could, you know, define your constants...

--
Nay, God Himself will not save men against their wills. -Locke
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: PHP Version 5.3.6
Next Topic: Accessing IIS variables from PHP after URL Rewrite
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 15:02:28 GMT 2024

Total time taken to generate the page: 0.02408 seconds