Dear all,

I have written php code in two files, "index.php" and index.inc",
The file index.inc is embedded in the "index.php". When I read the file index.php in the IE browser like "http://www.xxx.com/index.php? data=a", such variable "$data=a" is used in the file index.inc. However, when I test the variable by using statement <?echo $data?> in the index.inc, no value can be found. Why? please help me to solve this problem. I would appreciate for any of your help, thanks

Regards,
Simon

    Be careful of where you are including the file. If outside of a function then the file is included in the global scope and so all included variables become globals. If inside of a function then all variables become local to that function.

    When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward.

      Is Global Vars swtched off? If so you need to access $data from $_GET['data']
      HTH
      Bubble

        $GET and $POST only apply to submitted data e.g. via a form or a link etc 🙂

          Yes. I knew that. Honest.

          /me should read posts more thoroughly 😉

            Write a Reply...