php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21868 include()/require() bug
Submitted: 2003-01-24 15:57 UTC Modified: 2003-01-24 16:09 UTC
From: omikorn at yahoo dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.2.1 OS: Windoze
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: omikorn at yahoo dot com
New email:
PHP Version: OS:

 

 [2003-01-24 15:57 UTC] omikorn at yahoo dot com
A BIG ATTENTION!
let`s say that we have this 2 files include.php & test.php:
include.php
<?
$foo="blabla";
?>
and now test.php:
<?
require "include.php";
function do_test()
{
if ($foo) {echo "foo is set if called from function<br>";} else {echo "bang foo is not set if called from function<br>";}
}

do_test();
if ($foo) {echo "foo is set if called from main<br>";} else {echo "bang foo is not set if called from main<br>";}
Result of the program is:
bang foo is not set if called from function.
foo is set if called from main

Bug?
Server: Apache/1.3.26 (Win32) PHP/4.2.3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-24 16:09 UTC] moriyoshi@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You should use "global" declarations when you want to use global variables
in the functions.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 02:01:33 2025 UTC