Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error warnings

Status
Not open for further replies.

knuckle05

Programmer
Dec 17, 2001
247
CA
Hi,

I'm wondering if there is anyway to turn on / off the error warnings displayed by PHP. I keep getting Warnings for unset variables at the top of my page, but they aren't actually errors.

Thx
 
The PHP runtime configuration directive "display_errors" can turn off everything. Not a good idea.

The PHP runtime configuration directive "error_reporting" can be changed so that it does not report warnings. Better, but still not a good idea.

You can use the "@" error-suppression operator. Also not a good idea.

I strongly recommend that you check to see whether a variable is set before you try to use it:

if (isset($somevariable))
{
//then do something with the variable
}
else
{
//then do something else
}

or conditionally initialize the variable:

if (!isset($somevariable))
{
$somevariable = 'somevalue';
}

//use the variable here.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Sounds like you have error_reporting set to a high level (E_ALL for example). Try setting it to a lower level,
for example

error_reporting(E_ERROR+E_PARSE);


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top