PDA

View Full Version : include


Neo
06-16-2003, 07:31 PM
How is it that I can use include to obtain variables from another site. I tryed this but I did not work.

script on http://www.site1.com/vars.php

<?php

$VAR = "this is a test";

?>


script on http://www.site2.com/getvars.php

<?php

include 'http://www.site1.com/vars.php';

echo $VAR;

?>


I just have no clue..I looked on php.net but there was no real hlp as of how to do this.

Thanks
- Neon

assassingod
06-16-2003, 07:35 PM
Worked fine for me...

Cloudrunner
06-16-2003, 07:42 PM
<?php

include 'http://www.site1.com/vars.php';

echo $VAR;

?>

I believe that the include should look thusly:

<?php

include ('http://www.site1.com/vars.php');

echo $VAR;

?>

Since both include and require are functions of PHP...could be wrong of course...

amykhar
06-16-2003, 07:48 PM
With the way permissions are, you should read about including remote files. For security reasons, you can't just use variables in a file that you include from somebody else's site.

You can show the output of the file, but you can't access the variable values. If I recall correctly, fopen will let you use the variables, but you will need access permissions to the file. It's been a long time since I had to do this.

Search on Google for remote include php

filburt1
06-16-2003, 07:53 PM
More specifically: think about what you could do if you could have scripts between two servers interact. It would be a nightmare. Security would be gone.

Neo
06-16-2003, 10:33 PM
thats if you designed it without security measures. Thanks all for the info.