error_reporting (E_ALL); – PHP

  php

Q(Question):

I’ve been experimenting with using:

error_reporting (E_ALL);

However, lines like this report problems when the variable is missing:

$open = $_GET[‘open’];

Is there some way to do that with error reporting left turned on –
that *doesn’t* give a warning?

__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.

A(Answer):

[Fri, 21 Nov 2003 14:22:34 GMT] Tim Tyler <ti*@tt1lock.org> wrote:

error_reporting (E_ALL);

However, lines like this report problems when the variable is missing:
$open = $_GET[‘open’];

Is there some way to do that with error reporting left turned on –
that *doesn’t* give a warning?

Do you have register_globals turned off?

What warning exactly was it? Or was it a notice?

A(Answer):

Tim Tyler wrote:

I’ve been experimenting with using:

error_reporting (E_ALL);

However, lines like this report problems when the variable is missing:

$open = $_GET[‘open’];

Is there some way to do that with error reporting left turned on –
that *doesn’t* give a warning?

__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.

This will give you all error reports EXCEPT notices (which is what I get with an
undeclared variable).

error_reporting (E_ALL ^ E_NOTICE);

For more info, check out the following URL. You can just turn on specific
warning types by using the "|" to seperate them.

http://ca.php.net/manual/en/function…-reporting.php

Regards,
Shawn

Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com

A(Answer):

On 21-Nov-2003, Tim Tyler <ti*@tt1lock.org> wrote:

I’ve been experimenting with using:

error_reporting (E_ALL);

However, lines like this report problems when the variable is missing:

$open = $_GET[‘open’];

Is there some way to do that with error reporting left turned on –
that *doesn’t* give a warning?

if (isset($_GET[‘open’]))
$open = $_GET[‘open’];
else
$open = NULL;

or

$open = (isset($_GET[‘open’])) ? $_GET[‘open’] : NULL;


Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it’s reserved for spammers)

A(Answer):

Tim Tyler wrote:

I’ve been experimenting with using:

error_reporting (E_ALL);

However, lines like this report problems when the variable is missing:

$open = $_GET[‘open’];

Is there some way to do that with error reporting left turned on –
that *doesn’t* give a warning?

<?php
if (isset($_GET[‘open’] && (int)$_GET[‘open’]>0)
// don’t let users put anything but integers in $open !
$open = (int)$_GET[‘open’];
else
$open = 0; // 0 means bad input
?>


..sig

A(Answer):

On Fri, 21 Nov 2003 14:22:34 GMT, Tim Tyler <ti*@tt1lock.org> wrote:

I’ve been experimenting with using:

error_reporting (E_ALL);

However, lines like this report problems when the variable is missing:

$open = $_GET[‘open’];

Is there some way to do that with error reporting left turned on –
that *doesn’t* give a warning?

As well as the checks with isset posted by others, there’s:

$open = @$_GET[‘open’];

But only if NULL is an acceptable value for you to use.


Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

A(Answer):

Andy Hassall <an**@andyh.co.uk> wrote or quoted:

On Fri, 21 Nov 2003 14:22:34 GMT, Tim Tyler <ti*@tt1lock.org> wrote:

I’ve been experimenting with using:

error_reporting (E_ALL);

However, lines like this report problems when the variable is missing:

$open = $_GET[‘open’];

Is there some way to do that with error reporting left turned on –
that *doesn’t* give a warning?

As well as the checks with isset posted by others, there’s:

$open = @$_GET[‘open’];

But only if NULL is an acceptable value for you to use.

I guess if the syntax sugar is there anyway, you might as well use it.

Thanks very much to those who responded – it’s appreciated.

__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.

LEAVE A COMMENT