Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:22:01+00:00 2026-05-27T20:22:01+00:00

What I had BEFORE was… if(DEBUGMODE) $debug_err_msgs[] = ‘Some error’; // add a new

  • 0

What I had BEFORE was…

if(DEBUGMODE) $debug_err_msgs[] = 'Some error'; // add a new error to the array

... more code here...

if(DEBUGMODE)$debug_err_msgs[] = 'Some error'; // add a new error to the array

which worked great EXCEPT in functions. SO… I decided to make it GLOBAL by using the $_GLOBALS array. I originally liked the 1st method I chose because it kept adding to the array and I could dump it later on to view what was happening.. Using the $_GLOBALS['debug_err_msgs'] and $_GLOBALS['errorh_string'] is forcing me to .= (append) the string to the previous one (which is ok… I didn’t think you could go… $_GLOBALS['something'][] and keep adding to the array like I did before I changed my code. SO.. I made changes as below…

PHP

<?php
error_reporting(E_ALL);
set_error_handler("ErrorHandler");

$_GLOBALS['errorh_string'] = "";
if(DEBUGMODE) $_GLOBALS['debug_err_msgs'] = "";
if(DEBUGMODE) $_GLOBALS['debug_err_msgs'] .= 'La la la, some errors';
if(DEBUGMODE) $_GLOBALS['debug_err_msgs'] .= 'more errors... etc';

function ErrorHandler($errno, $errstr, $errfile, $errline)
{
    // if ($errno == 8) return;// 8 is undefined variables
    $error = "<b>Error[</b>$errno<b>] </b>$errstr<br />";
    $_GLOBALS['errorh_string'] .= $error; // append new error to the global string
    return true;    // dont execute the php internal error handler
}
?>

ERRORS IM GETTING

Notice: Undefined index: errorh_string in /debugOpenBlock.php on line 14

Notice: Undefined index: errorh_string in /debugOpenBlock.php on line 14

Which in the code above, is INSIDE the function

$_GLOBALS['errorh_string'] .= $error; // GIVES ME UNDEFINED

Here is what’s weird… if I change the line to read…

$_GLOBALS['errorh_string'] = $error; // NO ERROR NOW

I even tried

$_GLOBALS['errorh_string'] = $_GLOBALS['errorh_string'] . $error; // GIVES ME UNDEFINED

If 'errorh_string' is a literal? why do I get undefined in it.!?!??! Am I missing something about GLOBALS?

As I was writting this I was thinking I could have used

global $debug_err_msg[]; // make this array global

instead of changing all my code to the way I have it now but… I’m curious what this problem is now… I hate not knowing something 🙂

BTW – I just recently turned off register_globals in the PHP.INI file. Could this have anything to do with it (note: I NEVER used $_SESSION[‘somevariable’] as $somevariable (mainly because I didn’t know you could do that but… doesn’t matter anyways)).

I’ve read piles of articles about superglobals, register_globals etc but nothing sheds any light on this..

Awaiting wisdom oh greater than I web developers 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:22:02+00:00Added an answer on May 27, 2026 at 8:22 pm

    I can’t find another problem, so the issue seems that you just used the wrong variable name. It is called $GLOBALS, not $_GLOBALS – unlike the input arrays. (It’s not affected by the register_globals setting btw.)

     global $debug_err_msg;
    

    You should actually prefer this method. That makes using the variable more legible than with the $GLOBALS[] access, and it also shows that you intentionally share that variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had never had this error before, and I didn't move any file, or
I currently work with some code that is repeated - more specifically, code that
I am running into an issue I had before; can't find my reference on
Ok I have this problem that I've never had before, it's really bugging me.
I had this problem before and can't for life of me remember how to
Strangely I had this working before but I reinstalled my system, upgraded to w7
I've never had this issue before, so I'm somewhat lost. I'm getting two different
I know I've had this problem before so I'm really frustrated. I've got the
I had never heard of persistent connections before, and I don't understand the advantages.
I've had this problem many times before, and I've never had a solution I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.