(Source : PHP Mailing List - Rasmus Lerdorf [rasmus@lerdorf.com])
Functions defined in included files are always global. So I guess it is just the variable you want
to put out into the global symbol table. It's a little bit tricky, but you can do it like this:
<?
function foo ( $filename ) {
extract ( $GLOBALS , EXTR_REFS );
include $filename ;
$arr = array_diff ( get_defined_vars (), $GLOBALS );
foreach( $arr as $var => $val ) $GLOBALS [ $var ] = $val ;
}
?>
getting the name of the current script and query string Categories : PHP , Global Variables , Variables , URLs Initialize global variables for every field in a table.
This version requires that phplib is installed on your
server. Categories : Global Variables , MySQL , PHP , Variables How to make sure a that $foo is from a cookie and not from the URI. Categories : PHP , Variables , Global Variables , Cookies Make old style (PHP3) scripts using GET, POST, COOKIE and File uploads (POST) compatible with
PHP 4.2.0 Categories : PHP , HTML and PHP , Global Variables , Cookies , Variables Global Dump Highlighted Categories : PHP , Variables , Global Variables Simple script to passing persistent and growing array between recalls of one page (manipulate little stack). Categories : Arrays , Global Variables , PHP , HTML and PHP , Variables Pageinfo: Array containing page URI, page query string (parameters), request method (GET or POST) and the complete URI Categories : Variables , PHP Options and Info , Arrays , URLs , PHP Current Page's URL using PHP Categories : PHP , Beginner Guides , Global Variables Newbie Notes #5 - To double quote, or single quote, that is the question Categories : PHP , Beginner Guides , Variables Variable serialization and unserialization. Loading and saving variable structures
to and from file. Categories : Arrays , Filesystem , Variables , Strings , PHP Define equivalents in php3. Categories : PHP , Variables Automatic global variable definer Categories : PHP , Variables , Beginner Guides A quick way set data from a form to a function or other places where you can lose scope. Categories : PHP , HTML and PHP , Variables How to implement a session tracking system. Categories : PHP , Sessions , Variables Script to check values being submitted by POST or GET method from a form. This script may help diagnose what variables are being supplied by a browser to other php scripts. Categories : HTML , Variables , Debugging , PHP , HTTP