sorry for the confusion. i just realized i made a mistake in my orginal post... subsitute thefile.php for myfile.php in the first code block.
i totally get where your comming from nickvd and i now understand why i get the first var, but, what i'm trying to accomplish is getting the vars name and age in myfile.php. i just want getfile.php to pass them through so i can access them in myfile.php.
getfile.php's whole job is to read the contents of another php file, evaluate any php code in it (among other things), and echo the result. so what do i do if i need to pass vars to the file i'm evaluating (myfile.php)?
if i change "getfile.php?file=thefile.php
?name=jim&age=35" to "getfile.php?file=thefile.php
&name=jim&age=35" then sure enough, getfile.php has 3 vars, but myfile.php has 0 vars.
i know this probably seems like a silly thing to do given my sudo code above, like why don't i just include() myfile.php or just do MakeRequest( "myfile.php?name=jim&age=35", callback ); but getfile.php does more thngs to myfile.php like replacing string ids with literals from a string resource file... for example [#StrSomeString#] in myfile.php is replaced with "Some string" etc... hence the file_get_contents() call which seems to handle query string vars just fine.
--------------------------------
just as i was about to post this i thought of a solution:
if i replace the & with some other token like { then replace that token with & in getfile.php, it works!
so the code would look like:
index.php:
Code: Select all
MakeRequest( "getfile.php?file=myfile.php?name=jim{age=35", callback );
getfile.php:
Code: Select all
$file = $_GET[ file ];
$file = str_replace( '{', '&', $file );
$text = file_get_contents( $file );
// [do whatever with text]
echo( $text );
maybe not the prettiest solution but hell, it works! i'll have to be sure to pick a good token. what do you guys think, is there a better way to do this?
on another note, i just realized that file_get_contents() will evaluate all the php code in the target file so i don't need the code to look for <?php ?> blocks. strange, the php docs don't say anything about file_get_contents() doing any evaluation.
whew, sorry for the long arse post.
