NC (nc@iname.com) wrote:
: Aeon Twilight wrote:
: >
: > --------------------
: > return.php
: > --------------------
: > <?php
: > $var = 'PHP';
: > return $var;
: > ?>
: >
: > --------------------
: > noreturn.php
: > --------------------
: > <?php
: > $var = 'PHP';
: > ?>
: >
: > --------------------
: > testreturns.php
: > --------------------
: > <?php
: > $foo = include 'http://www.domainwhatever.com/return.php';
: > echo $foo; // should print 'PHP', but only prints 1
: > $bar = include 'http://www.domainwhatever.com/noreturn.php';
: > echo $bar; // prints 1
: > ?>
: > --------------------
: >
: > So, is it possible to return a value other than true or false
: > via an include over HTTP?
: Why do you need to return anything?
Perhaps just because the manual says you can?
However,
http://us4.php.net/include/ says "[1] This is not, however,
possible when including remote files [2] unless the output of the remote
file has valid PHP start and end tags (as with any local file). You can
declare the needed variables within those tags and they will be introduced
at whichever point the file was included. "
To me that's not clear whether section [2] means you can do it as long as
you output the tags, or whether section [2] says you can't but there is a
workaround, which it then descibes. (and which is also mentioned below).
You could try "echo'ing" the <?php and ?> tags to see if that changes
anything. something like
<?php echo '<?php'; $var='XXX'; echo '?>' ?> though if it works at
all then you may have to play with some combinations of syntax to find the
one that works (assuming it works at all).
All variables in the
: included code become available in the including code after
: the include(). So you can simply write:
: include 'http://www.domainwhatever.com/return.php';
: echo $var; // should print 'PHP'
: Cheers,
: NC
--
This space not for rent.