Undefined Variable? But I defined it...

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-04-27T03:44:37Z Indexed on 2010/04/27 3:53 UTC
Read the original article Hit count: 198

Filed under:
|

Well before anyone claims that theres a duplicate question... (I've noticed that people who can't answer the question tend to run and look for a duplicate, and then report it.)

Here is the duplicate you are looking for: http://stackoverflow.com/questions/2481382/php-claims-my-defined-variable-is-undefined

However, this isn't quite a duplicate. It gives me a solution, but I'm not really looking for this particular solution.

Here is my problem:

Notice: Undefined variable: custom

Now here is my code:

                $headers = apache_request_headers(); // Request the visitor's headers.
                $customheader = "Header: 7ddb6ffab28bb675215a7d6e31cfc759"; //This is what the header should be.
                        foreach ($headers as $header => $value) { 
                                $custom .= "$header: $value"; 
}

Clearly, $custom is defined. According to the other question, it's a global and should be marked as one. But how is it a global? And how can I make it a (non-global)? The script works fine, it still displays what its supposed to and acts correctly, but when I turn on error messages, it simply outputs that notice as well. I suppose its not currently necessary to fix it, but I'd like to anyway, as well as know why its doing this.

© Stack Overflow or respective owner

Related posts about php

Related posts about variables