Jump to content


Photo

Help with require() statement using URL_fopen_wrappers.


  • Please log in to reply
2 replies to this topic

#1 r3gan

r3gan
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 31 July 2006 - 02:38 PM

Can anyone give me some help on using a require() statement to include a PHP script from a different machine?  I am able to call & run the script via the require() statement because there are print() statements in the remote script that are echoed to the browser when I run my page, however I cannot get it to return anything from the remote script back to my local script.  The remote script is a .php extension and the remote machine is configured to parse PHP scripts, so the code is being processed on the remote machine.  How do I set up that remote script so that it will pass results / variables back to my calling script that I can use??

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 July 2006 - 02:48 PM

Require doesnt execute the code on the remote machine, instead it basically copy 'n' paste's the contents of the file being included/required into the script that is getting the file.

#3 r3gan

r3gan
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 31 July 2006 - 05:08 PM

The copy & paste idea works for local files being required, however it doesn't seem to behave the same way for my remote file.  Here's the setup:
[pre]-------------------------------------------------------------------------
Local file:
<?php
//
// some php code here
//
require("http://www.example.c...Dir/myFile.php");
if (isset($myVar))
  print $myVar;
else
  print "variable does not exist";
?>
-------------------------------------------------------------------------
Remote file:
<?php
$myVar = "variable exists";
?>
-------------------------------------------------------------------------
[/pre]

The example above prints "variable does not exist".  So the variable being created in the remote script is not sent back for use in the local php script.  Am I doing something wrong?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users