/// <summary> /// Initializes <c>_GLOBALS</c> array. /// </summary> /// <param name="registering_order"><c>EGPCS</c> or <c>null</c> if register globals is disabled (default).</param> protected virtual PhpArray InitGlobals(string registering_order = null) { Debug.Assert(_superglobals.request != null && _superglobals.env != null && _superglobals.server != null && _superglobals.files != null); var globals = new PhpArray(128); // estimates the initial capacity of $GLOBALS array: // adds EGPCS variables as globals: if (registering_order != null) { if (IsWebApplication) { Superglobals.InitializeEGPCSForWeb(globals, ref _superglobals); } else { Superglobals.InitializeEGPCSForConsole(globals, ref _superglobals); } } // adds auto-global variables (overwrites potential existing variables in $GLOBALS): globals[CommonPhpArrayKeys._GET] = PhpValue.Create(_superglobals.get); globals[CommonPhpArrayKeys._POST] = PhpValue.Create(_superglobals.post); globals[CommonPhpArrayKeys._COOKIE] = PhpValue.Create(_superglobals.cookie); globals[CommonPhpArrayKeys._FILES] = PhpValue.Create(_superglobals.files); globals[CommonPhpArrayKeys._ENV] = PhpValue.Create(_superglobals.env); globals[CommonPhpArrayKeys._REQUEST] = PhpValue.Create(_superglobals.request); globals[CommonPhpArrayKeys._SERVER] = PhpValue.Create(_superglobals.server); globals[CommonPhpArrayKeys._SESSION] = PhpValue.Create(_superglobals.session); globals[CommonPhpArrayKeys.GLOBALS] = PhpValue.CreateAlias(globals); // &$GLOBALS //// adds long arrays: //if (Configuration.Global.GlobalVariables.RegisterLongArrays) //{ // globals.Add("HTTP_ENV_VARS", new PhpReference(((PhpArray)Env.Value).DeepCopy())); // globals.Add("HTTP_GET_VARS", new PhpReference(((PhpArray)Get.Value).DeepCopy())); // globals.Add("HTTP_POST_VARS", new PhpReference(((PhpArray)Post.Value).DeepCopy())); // globals.Add("HTTP_COOKIE_VARS", new PhpReference(((PhpArray)Cookie.Value).DeepCopy())); // globals.Add("HTTP_SERVER_VARS", new PhpReference(((PhpArray)Server.Value).DeepCopy())); // globals.Add("HTTP_POST_FILES", new PhpReference(((PhpArray)Files.Value).DeepCopy())); // globals[CommonPhpArrayKeys.HTTP_RAW_POST_DATA] = HttpRawPostData; // // both session array references the same array: // globals.Add("HTTP_SESSION_VARS", Session); //} // return(globals); }