notice and warning




I turned on errors in php:

ini_set('display_errors','1');

And I got a slew of notices and a couple of warnings.

The notices are mostly missing indexes from doing things like this:

$some_var = $_REQUEST['some_name'];

And the warnings are when I have something like this:

Missing argument 1 ...

function someFoo($var1){
if($var1){...}
}

someFoo();

So, I turned display_errors back off, but wonder if I should do anything about the this.

What is good programming practice?

Generally I care more about whether a variable is null or empty, and not whether it has been set, which is what the "notices" seem to be about. If I were to do this:

if(isset($var1)){

// I'd still have to do this:

if($var1){...

PHP is a new language for me, and I'd like to write "correctly"...but I don't want to bloat the code either.

Oh, one more thing, I slipped into perl mode and did this: $SOME_ARRAY{some_key} and got no complaints, Is that "kosher"?

Jeff

.



Relevant Pages

  • Re: notice and warning
    ... Jeff wrote: ... And I got a slew of notices and a couple of warnings. ... The notices are mostly missing indexes from doing things like this: ...
    (comp.lang.php)
  • Re: $request problem
    ... $array['key'] is an array with the string 'key' as index. ... from OUTSIDE a doublequote'd string, ... The PHP manual says on this topic: ... That would explain why you get no warnings! ...
    (comp.lang.php)
  • Inclusion confusion (Javascript in function?)
    ... I am having a problem with the phpBB package. ... Cannot modify header information - headers already sent by (output ... and two more of the same warnings for lines 485 and 486. ... Am I the only one confused, or is the PHP 4.4.2 that my shared linux/Apache ...
    (comp.lang.php)
  • Re: Suppressing PHP Warnings from CLI
    ... > I have a couple of PHP scripts I use via cron and from the CLI. ... > appear to be a flag to silence these warnings. ... It's always better to fix the problem rather than cover up the symptom. ...
    (comp.lang.php)
  • Re: error handling issue - try / catch with PHP 5
    ... I have written some PHP code to index the contents of C drive ... on a Windows machine. ... When it gets to certain special folders (fake ... hmmm will read up more on Warnings. ...
    (comp.lang.php)