Found this in the manual, I understand it, but what if I was passing variables to the php file that has the includes in it? How do I get the variables that I am passing to that php file to be included into the "includes" if it can't be written as line 1?? This is driving me crazy, any help would be greatly appreciated!!!

1 include ("file.inc?varone=1&vartwo=2"); / Won't work. /
2
3 $varone = 1;
4 $vartwo = 2;
5 include ("file.inc"); / $varone and $vartwo will be available in file.inc /

    any variables available to the script calling the include is available to the included file. so if you call script.php with a url of script.php?varone=1&vartwo=2, then $varone and $vartwo will be available in file.inc .

    is this the question?

      That is part of the question. What I am doing is sending a variable thru a URL,and the value of that variable happens to be another URL. (http://www.yoursite.com/file.php?var=1)

      Once the php file I am sending this variable too gets it, I want to use that variable value in a "include" that is in that php file. So in THAT file it would eventually look something like this....

      include ($variabletoget);

      Where $variabletoget is the above value (http://www.yoursite.com/file.php?var=1)

        All include does is load a file into the physical place where you put the command. You could just as well copy and paste the code in there. So anything available in the scope of the main page is available in the include code.

        And what you include is a file not a URL... meaning that variables passed with ? will not be passed to the script. They are just a part of the file name string. What you need to do is split the variable in filename and arguments before loading the include.

        Pathinfo() might help you, but I think doing a custom function for the purpose might be necessary.

        In order to get the string og ?arg=1&param=2 converted to variables, your will probably need to turn to variable variables (check http://www.phpbuilder.com/columns/robert20000928.php3)

        Hope this helps

        Martin

          is it possible you just want to redirect to $variabletoget, rather than actually including it in the first script? if so, use header(). variable variables make my head spin

            Write a Reply...