Loading globals into classes
- From: Scott Johnson <noonehome@xxxxxxxxxxxxxxxxx>
- Date: Sun, 22 Jan 2012 09:20:54 -0800
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
.
- Follow-Ups:
- Re: Loading globals into classes
- From: J.O. Aho
- Re: Loading globals into classes
- Prev by Date: Very Huge collection of Solutions Manuals & Test Banks
- Next by Date: Re: Loading globals into classes
- Previous by thread: Check email
- Next by thread: Re: Loading globals into classes
- Index(es):