note 44378 added to function.include
| From: | norm at normsworld dot co dot uk | Date: | Wed, 04 Aug 2004 09:54:24 +0000 |
| Subject: | note 44378 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73907@lists.php.net to get a copy of this message | ||
Returning values from a remote include... I tried to do this:
remote_include.php
<?php
$foo = 'bar';
return $foo;
?>
local_file.php
<?php
$bar = include 'http://www.remote.com/remote_include.php';
echo $bar;
?>
It didn't work and I spent ages trying to find out why. It's simple really, but I though
others might slip up on it too. Basically, remote_include.php is parsed by the remote server and so
only gives back HTML... Change remote_include.php to this and it works:
<?php
echo "<?php \n";
echo " \$foo = 'bar'; \n";
echo " return \$foo; \n";
echo "?> \n";
?>
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44378
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44378&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44378&report=yes
Search -- http://master.php.net/manage/user-notes.php