If I include a local file, and set a variable
within the called file, it is still set
in the calling file.
If I use the http: address of the file, to
access it from a different server, it's not!
The split between the two servers (both mine)
is deliberate: one has access to a database
but no public IP, the other is a public web server.
I've been trying workarounds including passing
the variables back in an array or XML string, but include() only wants to return an integer!
Help, please!
Sample code:
included file:
<?php
Global $test1;
Global $RES;
$test1 = "bar";
echo "Inside: test1 = $test1";
$RES['test1'] = $test1;
return("This is a string");
?>
calling file:
<?php
echo phpversion();
echo "<br>try include<br>\n";
$test1 = "foo";
echo "test1 = $test1";
echo "<br>now including change of test1<br>";
$result = array();
echo "result is ".gettype($result);
$result = include("http://192.168.100.3/includechild.php");
echo "result is ".gettype($result);
echo "<br>outside: test1 = $test1";
echo "<br>result: $result";
extract($result);
echo "<br>extracted: test1 = $test1";
?>
Results:
4.0.5
try include
test1 = foo
now including change of test1
result is arrayInside: test1 = barresult is integer
outside: test1 = foo
result: 1
Warning: extract() expects first argument to be an array in /home/httpd/html/Services/PostAdvisor/parent.php on line 15
extracted: test1 = foo