The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If Config::get() doesn't match it should return false
#3
Not in UserSpice, but in my own app.

My philosophy in starting with UserSpice is that I want to build on the framework that is there to the greatest extent possible (not reinventing the wheel). Thus since you had a config class already in place I just add my config elements to your system.

However, my basic approach to configured elements is to always provide a (hopefully reasonable) default. So I always check if the item exists in the Config file and, if not, I provide this default like this:

Code:
$myCfgItem = Config::get('myapp/mycfgitem') ? : 'my default';

What I ran into was that the
Code:
Config::get()
was returning the whole
Code:
$config
array and thus instead of a value I was getting an array in my variable.

It's very possible I'm not using Config in the way it was intended - for all my suggestions please take them as just that: suggestions.

I will confess I'm going to have a bear of a time the next time I upgrade UserSpice... :-) But that's on my head - you clearly communicated that I should use the
Code:
usersc
directory...
  Reply


Messages In This Thread
If Config::get() doesn't match it should return false - by plb - 09-02-2016, 04:12 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)