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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:45:00+00:00 2026-05-16T11:45:00+00:00

I have this PHP class, whose purpose is to fetch some configuration data from

  • 0

I have this PHP class, whose purpose is to fetch some configuration data from a database and store it for later use:

class GSConfig {
  private $configurationData;
  private $repository;

  public function __construct($pRepository) {
    $this->repository = $pRepository;
    $this->configurationData = $this->InitializeConfiguration();
  }

  public function InitializeConfiguration() {
    $result = $this->repository->configLoadAll();
    if ( $result['data'] ) {
      $conf_array = $result['data'];
      foreach ( $conf_array as $row) {
        $code = strtolower($row ['code']);
        $value = strtolower($row ['value']);
        //if ($value == "true") $value = (bool)true;
        //if ($value == "false") $value = (bool)false;
        $this->configurationData[$code] = $value;
      }
    } else {
      $this->configurationData = null;
    }
    print_r($this->configurationData);
  }

  public function getConfigValue($key) {
    $key = strtolower($key);
    if ($this->configurationData != null) {
      if( isset($this->configurationData[$key])) {
        return $this->configurationData[$key];
      }
    } else if ($this->configurationData == null) {
      // If we reach this code, something went wrong
      // (TODO: throw Exception)
      echo "<p>Tick</p>";
    }
  }
}

InitializeConfiguration gets the data and stores it as an array in the $configurationData property. This is working as expected as shown by the output of the print_r function.
However, after initializing, if i attempt to read any value from the $configurationData, i get Tick. Somehow the variable becomes null after the Initialization.

The output would be something like:

print_r output:
Array ( [show_cart] => true [order_mail] => order@shop.de [debug_mode] => true [branch_mode] => true [default_branch] => 1 [agb_file] => agb.txt [kat_order] => k_nr [show_rows] => 5 [product_order] => p_produktnr [cost_per_wu] => 0.66 [message_lang] => eng [free_shipping] => true [free_ship_amt] => 25 [special_price] => true [discounts] => true [cat_show_mode] => all [price_att] => ersatzpreis [mwst_att] => mehrwertsteuer [aktionsp_att] => aktionspreis [katalog_mode] => per_branch )
further output: 
Tick
Tick
...
Tick

Anyone knows why this is happenning? Btw, my PHP version is 5.3.1

  • 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-16T11:45:01+00:00Added an answer on May 16, 2026 at 11:45 am

    you’re assigning the return value of InitializeConfiguration() but there’s no return statement in this function (defaults to “return null”).

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

Sidebar

Related Questions

Lets say I have this code: <?php class hello { var $greeting = hello;
I have a script which similar to this: foo.php class Foo { function Foo()
Hallo I have this script: <? require(lib2/config.inc.php); require(lib2/tpl.class.php); require(lib2/db.class.php); require(lib2/um.class.php); $tpl = new template(templates,
I have this in my class When the second function is called php errors
I have a files structure like this: Class (folder): - User.php - Rule.php Scripts
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
I have this PHP script which i'm grabbing images from a directory and displaying
I use this class to crop, resize my image: http://www.phpclasses.org/package/4268-PHP-Resize-crop-rotate-flip-flop-and-grey-images.html It uses GD. The
I'm making a PHP class that handles some traffic with the use of CURL
I have a code block looking something like this: <p class=cont> <a href=otherpage.php class=link><img

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.