|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-11-21 14:45 UTC] brianlmoon@php.net
[2001-11-21 16:08 UTC] torben@php.net
[2001-11-21 16:21 UTC] bate@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 03:00:01 2025 UTC |
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