Hello everyone,

I have a question about variable scope that I probably should know the answer to but it is a puzzle at the moment.

I have a packaged script that I work on that has this problem but I can simplify the question with an example.

I have a scipt routine that collects a user IP address from $_SERVER['REMOTE_ADDR']. If I have $ip = $_SERVER['REMOTE_ADDR']; defined in the script, no problem but if I put the definition in an include statement like "require_once" it has no value but if I put the definition in a function in the include file and call the function, it contains the user IP address. By the way, the mod I am doing is for tracking badguys activity on a client site so I can see what parts of the script they are trying to access. I am collecting a lot more than just the ip address but this is a simplified example.

In the case I am working on, the definitions are in a header file and the IP collector is at the top of all the pages of the script. I have other "hardcoded" values defined in the header file that work?

Any ideas on what my problem is? I have created a function in the header file as a work around but I am wondering why the simple definition does not get parsed or why some variables work and others do not?

If the answer is obvious and I just don't get it, I hope someone can enlighten me. Thanks in advance.

mikesz



_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to