php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14164 variables set in remotely include()d file are lost upon return
Submitted: 2001-11-21 14:35 UTC Modified: 2001-11-21 16:21 UTC
From: steve at petabit dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.5 OS: Linux
Private report: No CVE-ID: None
 [2001-11-21 14:35 UTC] steve at petabit dot com
When using http to include() or require() a file,
the variables set within are lost when returning
to the calling file. 
Behavior is instead as expected when included or required file is local.

Example:

<?php
 
echo phpversion();
 
echo "<br>try include<br>\n";
$test1 = "foo";
echo "test1 = $test1";
echo "<br>now including change of test1<br>";
include("http://192.168.100.3/includechild.php");
echo "<br>outside: test1 = $test1";
echo "<br>result:  $result";
 
echo "<br>now try require<br>\n";
$test2 = "foo";
echo "test2 = $test2";
echo "<br>now requiring change of test2<br>";
require("http://192.168.100.3/requirechild.php");
echo "<br>outside: test2 = $test2";
?>   

includechild.php:  (and similar to requirechild.php)
-----------------

<?php
$test1 = "bar";
echo "Inside: test1 = $test1";
?>   

Results:
-----------

4.0.5
try include
test1 = foo
now including change of test1
Inside: test1 = bar
outside: test1 = foo

now try require
test2 = foo
now requiring change of test2
Inside: test2 = bar
outside: test2 = foo

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-21 14:45 UTC] brianlmoon@php.net
The file that is served remotely is being parsed on that server, not the local one.  You would have to have the remote server serve .php files as plain text to achieve what you want.
 [2001-11-21 16:08 UTC] torben@php.net
Change your included file extensions from .php to something
which the remote server won't parse, so that you're 
including the *text* of the remote file, not its *output*.


 [2001-11-21 16:21 UTC] bate@php.net
:) but i think he want that his code executed on the remote machine. He want just an resource_id #xxx to use it local.


Btw. due this way its possible to execute external code on a othersite. ?include=myfile.php are a very high security risk.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 11 14:01:28 2024 UTC