hey guys,
I've used the following code plenty of times before:
<?php require_once('http://www.domain.net/news.txt'); ?>
Im wanting to make this dynamic:
<?php require_once('http://www.domain.net/$file'); ?>
so I can go to domain.net/index.php?file=text.txt
what is the correct way of doing this?
thanks
stewart
If I am not mistaken you almost answered your own post
<?php require_once('http://www.domain.net/index.php?file=text.txt'); ?>
I believe your problem is that your using ' single quotations ' instead of double.
$var = "variable";
echo '$var'; \ will output $var
echo "$var"; \ will output variable
Try this instead
<?php require_once("http://www.domain.net/$file"); ?>
I was a little rushed for time when I posted my previous reply. If I had thought it through I would have noticed that there is a security risk in doing it that way.
Here is a post that might give you a clearer understanding of how best to do this. http://www.phpbuilder.com/board/showthread.php?s=&threadid=10287266
Thanks Megahertza, the code now works. Thanks shane for letting me know about the risk involve....I did wonder at the time. I guess there is a possibility remote scripts could be executed this way. Think I might have to look into changing it to something similar to yours.