Scrape PHP Globals
This pair of scripts let you extract explicitly declared global variables from a PHP script. In other words, they’ll extract all variables that occur between the word “global” and a semicolon. The result is a global command containing those variables, wrapped at a particular column width. I’ve implemented this both in PHP and in Perl.
Comments, bug reports, and other issues can be discussed on my forums.
Also, please note that I am not keeping the version numbers between the two scripts in sync. In other words, version 0.1 of the PHP version is not equivalent to version 0.1 of the Perl version. (In this case, verison 0.1 of the PHP version is in step with version 0.2 of the Perl version.)
Downloads
[ source ] [ .tar.gz ] [ .zip ]
[ source ] [ .tar.gz ] [ .zip ]
PHP Scrape PHP Globals
Usage
The script contains a function, find_globals, that may be included within another PHP script to extract the globals in yet another PHP script. The function returns a string containing the globals command.
Syntax
string find_globals($filename[, $cols]);
Parameters
- filename
- The php script you want to extract declared globals from.
- columns
- The number of columns wide you would like the output to be. Default is 79. A negative value will disable column wrapping.
Version History and Changelog
Perl Scrape PHP Globals
Usage
Perl must be installed on your system to use this script. To display a short usage note at the command line, pass “-h” or “–help” as an option instead of the filename.
Syntax
perl scrape.pl filename [columns]./scrape.pl filename [columns]
Parameters
- filename
- The php script you want to extract declared globals from.
- columns
- The number of columns wide you would like the output to be. Default is 79. A negative value will disable column wrapping.