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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:36:04+00:00 2026-05-19T13:36:04+00:00

I have a pre-existing object called Information , which contains login/user information. I would

  • 0

I have a pre-existing object called Information, which contains login/user information. I would like to access this from another class. I tried Googling and searching for ages… no luck. Why would the Information object be out of scope?

class foo() {
 function display() {
   print_r($Information);
 }
}
  • 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-19T13:36:05+00:00Added an answer on May 19, 2026 at 1:36 pm

    $Information could be out of scope for many reasons.

    First, maybe $Information is global and you just need to tell php with the global keyword:

    class foo() {
     function display() {
       global $Information
       print_r($Information);
     }
    }
    

    Second, maybe $Information is part of the foo instance? In this case, in php, you need the “$this” keyword.

    class foo() {
     function display() {       
       print_r($this->Information);
     }
    }
    

    Third, maybe $Information was created in the caller of display and display/foo simply know nothing about it.

    function bar() 
    {
       $Information = new $information;
       $a = new Foo();
       $a->display();
    {
    

    Unless you explicitely pass $Information to display, or make it a member variable of each Foo instance, display won’t be able to access it. display can see (1) global variables (2) instance variables, (3) parameters to display, and (4) variables local to display. Nothing else is within the scope of display().

    Edits to answer your questions
    Yes by global I mean it was initially defined as global. As in not within a specific function ie:

    There’s plenty of reasons to avoid globals. Plenty has been written on the topic. Here’s a stackoverflow question on the topic.

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

Sidebar

Related Questions

I have a pre-existing c++ object model which represents the business layer tier of
I have an empty sqlite3 db. I would like to import a pre-existing one
I have a login.jsp page which contains a login form. Once logged in the
I have a block of preformatted code (<pre>) which overflows horizontally so there is
I have this simple php script <?php echo '<pre>'; // Outputs all the result
I started switching some pre-existing nHibernate code in a Sharepoint-based ASP.NET project from eager
I'm creating a Java applet from a large scale pre-existing project (Vizster). I am
I've learned that in function invocation, this would refer to the global object. In
I need to inline css from a stylesheet in c#. Like how this works.
I have a query that I'd like to pre-compile, however the query is being

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.