php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52793 Output of example code at documention is not as described
Submitted: 2010-09-07 16:22 UTC Modified: 2010-09-08 12:19 UTC
From: jurciks66 at inbox dot lv Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Linux
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: jurciks66 at inbox dot lv
New email:
PHP Version: OS:

 

 [2010-09-07 16:22 UTC] jurciks66 at inbox dot lv
Description:
------------
Copy and run code from manual about $GLOBALS (http://php.net/manual/en/reserved.variables.globals.php)

Actual output is: 

$foo in global scope: 
$foo in current scope: local variable


Expected result:
----------------
I`m expecting to see the same output as seen on documentation page


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-07 16:26 UTC] rquadling@php.net
-Status: Open +Status: Bogus
 [2010-09-07 16:26 UTC] rquadling@php.net
[2010/09/07 15:23:31] [Z:\] [\\richardquadling\scratch$ ] >php
<?php
function test() {
    $foo = "local variable";

    echo '$foo in global scope: ' . $GLOBALS["foo"] . "\n";
    echo '$foo in current scope: ' . $foo . "\n";
}

$foo = "Example content";
test();
?>
^Z
$foo in global scope: Example content
$foo in current scope: local variable

Code and example output agree.
 [2010-09-08 10:43 UTC] jurciks66 at inbox dot lv
well, sorry about wrong problem description. my test file was parsed by another file, so, actual test script would look like this - 

<?php

	function test2() {
		function test() {
		    $foo = "local variable";

		    echo '$foo in global scope: ' . $GLOBALS["foo"] . "\n";
		    echo '$foo in current scope: ' . $foo . "\n";
		}

		$foo = "Example content";
		test();
	}

	test2();
?>

So I`m still wondering why my output is -

$foo in global scope: 
$foo in current scope: local variable
 [2010-09-08 12:19 UTC] rquadling@php.net
The bug system is not a support channel.

If you need support please contact the appropriate mailing lists via 
http://www.php.net/mailing-lists.php

Specifically to answer your question, please read about variable scope : 
http://docs.php.net/manual/en/language.variables.scope.php
 [2010-09-08 13:20 UTC] jurciks66 at inbox dot lv
Thanks for your time and sorry for the trouble
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 02:01:30 2024 UTC