Viewed   52 times

is there a way to create my own custom superglobal variables like $_POST and $_GET?



Static class variables can be referenced globally, e.g.:

class myGlobals {

   static $myVariable;


function a() {

  print myGlobals::$myVariable;

Saturday, August 13, 2022

Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):

$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>

The -d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):

vagrant@homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages.  More than one package may be
specified at once.  Prefix with channel name to uninstall from a
channel not in your default channel (

  -r, --register-only
        do not remove files, only register the packages as not installed

The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).

Monday, December 12, 2022
$level_count = 6

for ($i=1; $i<=$level_count; $i++) {
    $l = "level" . $i;
    $$l = array();

But Zerkms is right...

$arr = array(array(),array(),array(),array(),array(),array());
Monday, September 26, 2022

Writing the variables to a specific memory address and reading and writing to/from that address with information such as a count might work.

An (old) article on IPC (inter process communication) might help you

Out of interest why is it you don't want to use files or a database?

Another solution (despite more than likely technically using files or a database) would be to force the script to use a specific session ID.


$maximum = 1;


if( !isset( $_SESSION['count'] ) ) {
    $_SESSION['count'] = 1;
} else {
    if( $_SESSION['count'] >= $maximum ) {
        die( "too many processes running" );
    } else {


// simulate running something




echo "<br />executed";


Note in the example above, the call to session_write_close() is important because the execution of the script will prevent the counter being incremented until it finishes otherwise. And then as it closes it, it needs reopening to decrement the counter.

Obviously because of the session reopening, any output from the script would need to be buffered (see to prevent headers already sent errors

Tuesday, December 13, 2022

Never used any of those, but they look interesting..

Take a look at Gearman as well.. more overhead in systems like these but you get other cool stuff :) Guess it depends on your needs ..

Friday, November 11, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :