FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Loading globals into classes
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Loading globals into classes [message #176759] Sun, 22 January 2012 17:20 Go to previous message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma:
Senior Member
I have arrays set up in a separate included file and would like to
access them in a class.

I have a working solution but am wondering if there is not a better
approach more practical for this.

What I have that works is as follows (so far):

private $uom_ary;
private $months_ary;

public function __construct()
{
global $uom_ary;
global $months_ary;
$this->uom_ary = $uom_ary;
$this->months_ary = $months_ary;
}

Previously I just used the global at the top of each method but had to
add it for each method needing the array.

Any ideas an a better approach and the pitfalls to what I am currently
using would be appreciative.

Thanks
Scotty
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: list() Struktur auslagern
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 02:36:03 GMT 2024

Total time taken to generate the page: 0.04499 seconds