note 3603 modified in functions by sander

From: Date: Sun, 21 Apr 2002 18:51:02 +0000
Subject: note 3603 modified in functions by sander
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-29651@lists.php.net to get a copy of this message
Important Note to All New Users: functions do NOT have default access to GLOBAL variables. You must specify globals as such in your function using the 'global' type/keyword. See the section on variables:scope. This note should also be added to the documentation, as it would help the majority of programmers who use languages where globals are, well, global (that is, available from anywhere). The scoping rules should also not be buried in subsection 4 of the variables section. It should be front and center because I think this is probably one of the most non-standard and thus confusing design choices of PHP. [Ed. note: the variables $_GET, $_POST, $_REQUEST, $_SESSION, and $_FILES are superglobals, which means you don't need the global keyword to use them inside a function] --was-- Important Note to All New Users: functions do NOT have default access to GLOBAL variables. You must specify globals as such in your function using the 'global' type/keyword. See the section on variables:scope. This note should also be added to the documentation, as it would help the majority of programmers who use languages where globals are, well, global (that is, available from anywhere). The scoping rules should also not be buried in subsection 4 of the variables section. It should be front and center because I think this is probably one of the most non-standard and thus confusing design choices of PHP. http://www.php.net/manual/en/functions.php

« previous php.notes (#29651) next »