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 6904383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:03:16+00:00 2026-05-27T08:03:16+00:00

I am stuck with this confusion where I don’t understand why my global $error

  • 0

I am stuck with this confusion where I don’t understand why my global $error under my HelperClass() returns empty, where I could verify that $class->error is indeed filled up with data earlier on.

Is there some sort of issues with namespace in this case that I am not aware about? Please give me some pointers.

Here are some of the codes that are relevant.

Under Main file

namespace Core;
$class = new ControllerClass();
$error = $class->error;
// verified that $error prints correctly here
include ViewFile.php;

Under ViewFile.php

$helper = new HelperClass();
// __autoload function took care of the include

Under HelperClass:

namespace Core\Skeleton;

class HelperClass {
public function __construct() {
global $error;
// $error != $class->error as defined earlier    
// $error is empty here
}
  • 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-27T08:03:17+00:00Added an answer on May 27, 2026 at 8:03 am

    If you’re using an autoloader or include your classes from within another helper function, then the $error variable was never declared in the ‘global’ scope. It ended up in some local, and got disposed.

    Declare it shared right before you assign it a value.

    namespace Core;
    $class = new ControllerClass();
    global $error;
    $error = $class->error;
    

    Also while there is nothing wrong with shared variables per se. The name $error seems slightly too generic. Maybe you can up with a less ambigious or more structured exchange variable. $GLOBALS["/var/log"]["controller_error"] or something arrayish.

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

Sidebar

Related Questions

I'm kinda stuck with this one so I hoped someone could help me. I
I'm stuck with this already for some weeks and I don't have the faintest
I've come a bit stuck this afternoon with a bug in my web application
Im stuck with this little project in C# but basically my problem is this:
I am stuck on this problem which I am studying for an exam tomorrow.
I have been stuck on this for days, and was wondering if anyone had
I'm kinda stuck on this decision. My project already uses Spring and Spring Blazeds
I've been stuck with this for weeks now and have no idea where I'm
I'm stuck with this. I'm self studying assenbler and translating some basics instructions. But
Hey, in a tutorial C++ code, I found this particular piece of confusion: PlasmaTutorial1::PlasmaTutorial1(QObject

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.