|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-11-04 16:32 UTC] vrana@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 23:00:01 2026 UTC |
Description: ------------ Qualifying a variable with the keyword global has a tricky but undocumented effect -- it doesn't merely allow code in a function to access global variable, but it actually creates global variables. This should be clearly described in the manual. Reproduce code: --------------- function main() { global $num; $num = 10; test(); } function test() { $number = $GLOBALS['num']; echo "num = $number"; } Expected result: ---------------- num = because $num isn't declared outside all functions Actual result: -------------- num = 10