Re: User Authentication Continued....
| From: | Chris Shiflett | Date: | Fri, 03 Oct 2003 19:44:34 +0000 |
| Subject: | Re: User Authentication Continued.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164963@lists.php.net to get a copy of this message | ||
--- Jeff McKeon <jmckeon@telaurus.com> wrote:
> The problem I'm having is with the $_GET variables. I guess I'm not
> declaring them correctly. Do I need to set them as soon as the page
> loads, and outside of any functions like so..
>
> [code start]
> $custid = $_GET['custid'];
> $custname = $_GET['custname'];
> [code end]
>
> Or do I need to declare them in each funtion?
>
> [code start]
> Function blah(){
> global $custname, $custid;
>
> $custid = $_GET['custid'];
> $custname = $_GET['custname'];
> DO SOME STUFF....
> }
$_GET is a superglobal, which just means that it is always available
everywhere. If you assign $custname to $_GET['custname'], you now have a
regular global variable (if the assignment is done outside a function) or a
local variable (if the assignment is done within a function).
So, either just use $_GET['custname'] everywhere you need it, or work with the
variable scope like you would have to if it was anything else. For example:
1. $foo = $_GET['foo'];
2. $foo = 'bar';
The variable scope of $foo would be the same, regardless of which of those
assignments were made.
Hope that helps.
Chris
=====
My Blog
http://shiflett.org/
HTTP Developer's Handbook
http://httphandbook.org/
RAMP Training Courses
http://www.nyphp.org/ramp