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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:10:18+00:00 2026-05-20T18:10:18+00:00

I store all variables settings for some project in a class named Ini .

  • 0

I store all variables settings for some project in a class named Ini. Variables are stored in group of arrays. For example, I have several arrays – one for ‘database’ related stuff, another for ‘debug’ related stuff and so on.

So to access for example some settings in my code i would type:

$ini = new Ini();
echo $ini->database['user'];
echo $ini->debug['mode'];

I don’t like my way of doing this. I would like to access variables stored inside Ini class like this:

$ini->database->user;

or

$ini->debug->mode;

The problem is that i am referencing non existing object inside another object. And i found no way to catch such call and return values stored in original Ini object (via PHP __get() method)

Would appreciate some help finding solution to my problem.

  • 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-20T18:10:19+00:00Added an answer on May 20, 2026 at 6:10 pm

    Just create objects of the standard class:

    $a = new stdClass;
    $a->database = new stdClass;
    $a->database->host = 'localhost';
    
    
    echo $a->database->host;
    

    as an optional choice, you can take your existing arrays and cast them to objects and access with the same syntax:

    $a = new stdClass;
    $a->database = new stdClass;
    $a->database = (object)array('host' => 'localhost');
    
    
    echo $a->database->host;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a requirement in project to store all the revisions(Change History) for the
I normally store all my configs in the registry. Even though I have started
I have a properties file in java, in which I store all information of
I have problem with return statment >.< I want to store all magazine names
If all of my __init__.py files are empty, do I have to store them
Is there any way to make Visual Studio 2008 Express store all the files
Quicktime has a rich metadata API, allowing one to store all sorts of arbitrary
First of all, let's define a few tables: Users table will store information about
The title pretty much says it all. I'm using a TClientDataset to store an
I have a table that stores all the volunteers, and each volunteer will be

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.