Hi,
I'm trying to include a file via http. The remote file is querying a db on the remote server and returning the results.I am then trying to get the result assigned to a vairiable and use it within my local script.
I can echo out the results in the remote file [ the echo is in the remote file] and this works fine, however i want to return a variable that holds the output. When i do this I only get '1' returned even when i test a very simple file??
here is some code
remotefile.php
<?php
$myVar = 'test return value';
return $myVar;
?>
local script:
<?php
$myResult = include' http://www.otherdomain.com/remotefile.php';
echo $myResult;
?>
the echo in the last script always returns 1??
any ideas?
thanks
Include via http
Moderator: General Moderators
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
PHP Manual wrote:$bar is the value 1 because the include was successful. Notice the difference between the above examples. The first uses return() within the included file while the other does not.Code: Select all
return.php <?php $var = 'PHP'; return $var; ?> noreturn.php <?php $var = 'PHP'; ?> testreturns.php <?php $foo = include 'return.php'; echo $foo; // prints 'PHP' $bar = include 'noreturn.php'; echo $bar; // prints 1 ?>