error_reporting (E_ALL);

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Tyler

    error_reporting (E_ALL);

    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/ tim@tt1lock.org Remove lock to reply.
  • billy chan

    #2
    Re: error_reporting (E_ALL);

    [Fri, 21 Nov 2003 14:22:34 GMT] Tim Tyler <tim@tt1lock.or g> wrote:[color=blue]
    > 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?[/color]

    Do you have register_global s turned off?

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

    Comment

    • Shawn Wilson

      #3
      Re: error_reporting (E_ALL);

      Tim Tyler wrote:[color=blue]
      >
      > 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/ tim@tt1lock.org Remove lock to reply.[/color]

      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.

      PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


      Regards,
      Shawn
      --
      Shawn Wilson
      shawn@glassgian t.com

      Comment

      • Tom Thackrey

        #4
        Re: error_reporting (E_ALL);


        On 21-Nov-2003, Tim Tyler <tim@tt1lock.or g> wrote:
        [color=blue]
        > 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?
        > -[/color]

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

        or

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

        --
        Tom Thackrey

        tom (at) creative (dash) light (dot) com
        do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

        Comment

        • Pedro Graca

          #5
          Re: error_reporting (E_ALL);

          Tim Tyler wrote:[color=blue]
          > 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?[/color]

          <?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

          Comment

          • Andy Hassall

            #6
            Re: error_reporting (E_ALL);

            On Fri, 21 Nov 2003 14:22:34 GMT, Tim Tyler <tim@tt1lock.or g> wrote:
            [color=blue]
            >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?[/color]

            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 (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
            Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

            Comment

            • Tim Tyler

              #7
              Re: error_reporting (E_ALL);

              Andy Hassall <andy@andyh.co. uk> wrote or quoted:[color=blue]
              > On Fri, 21 Nov 2003 14:22:34 GMT, Tim Tyler <tim@tt1lock.or g> wrote:[/color]
              [color=blue][color=green]
              >>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?[/color]
              >
              > 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.[/color]

              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/ tim@tt1lock.org Remove lock to reply.

              Comment

              Working...