php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51840 definitions of global varaibles not working properly
Submitted: 2010-05-17 16:51 UTC Modified: 2010-05-17 16:56 UTC
From: christian dot gnoth at arcor dot de Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.2.13 OS: Linux x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: christian dot gnoth at arcor dot de
New email:
PHP Version: OS:

 

 [2010-05-17 16:51 UTC] christian dot gnoth at arcor dot de
Description:
------------
hi,

I would like to define few variables global so that I can use them in all functions - also if I include a php file with functions.

actually I expect, that if I declare a variable outside the functions as global, that those variables are available inside the functions.

Test script:
---------------
global $var1;

function funct1()
{
  echo $var1;
}


include 'incl_file1';

incl_dile1:
function funct2()
{
  echo $var1;
}


Expected result:
----------------
should work without problem or notice that var1 is not defined...


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-17 16:56 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-05-17 16:56 UTC] johannes@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

Please re-read the chapter how scoping works in PHP.
http://php.net/manual/en/language.variables.scope.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 16:01:31 2024 UTC